# include <bits/stdc++.h>

# define fi first
# define se second
# define ll long long
# define speed ios_base::sync_with_stdio(false)

const int N = 3e5 + 10;

using namespace std;

int xa,xb,ya,yb;
int n,ans;
int B[1010][3];

bool check(int x,int y)
{
	for (int i = 0;i < n;i++){
		int s = ceil(sqrt((x - B[i][0]) * (x - B[i][0]) + (y - B[i][1]) * (y - B[i][1])));
		if (s <= B[i][2])return false;
	}
	return true;
}

int main()
{
	speed;
	cin>>xa>>ya>>xb>>yb;
	cin>>n;
	for (int i = 0;i < n;i++)
		cin >> B[i][0] >> B[i][1] >> B[i][2];

	if (xa > xb){
		swap(xa,xb);
		swap(ya,yb);
		}

	for (int i = xa;i <= xb;i++){
		ans += check(i,ya);
		ans += check(i,yb);
	}
	for (int i = yb + 1;i < ya;i++){
		ans += check(xa,i);
		ans += check(xb,i);
	}
	cout<<ans;
	return 0;
}


# include <bits/stdc++.h>

# define fi first
# define se second
# define ll long long
# define speed ios_base::sync_with_stdio(false)

const int N = 3e5 + 10;

using namespace std;

int xa,xb,ya,yb;
int n,ans;
int B[1010][3];

bool check(int x, int y)
{
	for (int i = 0;i < n;i++){
		if ((x - B[i][0])*(x - B[i][0])+(y - B[i][1])*(y - B[i][1]) <= B[i][2]*B[i][2])return false;
	}
	return true;
}

int main()
{
	speed;
	cin>>xa>>ya>>xb>>yb;
	cin>>n;
	for (int i = 0;i < n;i++)
		cin >> B[i][0] >> B[i][1] >> B[i][2];

	if (xa > xb)swap(xa,xb);
	if (ya > yb)swap(ya,yb);

	for (int i = xa;i <= xb;i++){
		ans += check(i,ya);
		ans += check(i,yb);
	}

	for (int i = ya + 1;i < yb;i++){
		ans += check(xa,i);
		ans += check(xb,i);
	}

	cout<<ans;
	return 0;
}


//    >File Name: 103B.cpp
//    > Author: Webwei

#include<iostream>
#include<algorithm>
using namespace std;
int a[2005][2005];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int sum1=0,sum2=0;
	int xa,xb,ya,yb;
	cin>>xa>>ya>>xb>>yb;
	xa=xa+1000,ya=ya+1000,xb=xb+1000,yb=yb+1000;
	if(xa>xb) swap(xa,xb);
	if(ya>yb) swap(ya,yb);
	for(int i=xa;i<=xb;i++){
		for(int j=ya;j<=yb;j++){
			a[i][j]=1;
		}
	}
	for(int i=xa+1;i<=xb-1;i++){
		for(int j=ya+1;j<=yb-1;j++){
			a[i][j]=0;
		}
	}
	int n;
	cin>>n;
	int x,y,r;
	for(int i=0;i<n;i++){
		cin>>x>>y>>r;
		x=x+1000,y=y+1000;
		for(int i=xa;i<=xb;i++){
			for(int j=ya;j<=yb;j++){
				if(a[i][j]==1){
					if((i-x)*(i-x)+(j-y)*(j-y)<=r*r)  a[i][j]=0;
				}
			}
		}
	}
	for(int i=xa;i<=xb;i++){
		for(int j=ya;j<=yb;j++){
			if(a[i][j]==1)  sum2++;
		}
	}
	cout<<sum2<<"\n";
}


//    >File Name: 103B.cpp
//    > Author: Webwei

#include<iostream>
#include<algorithm>
using namespace std;
int a[2005][2005];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int sum1=0,sum2=0;
	int xa,xb,ya,yb;
	cin>>xa>>ya>>xb>>yb;
	xa=xa+1000,ya=ya+1000,xb=xb+1000,yb=yb+1000;
	if(xa>xb) swap(xa,xb);
	if(ya>yb) swap(ya,yb);
	for(int i=xa;i<=xb;i++){
		for(int j=ya;j<=yb;j++){
			a[i][j]=1;
		}
	}
	for(int i=xa+1;i<=xb-1;i++){
		for(int j=ya+1;j<=yb-1;j++){
			a[i][j]=0;
		}
	}
	int n;
	cin>>n;
	int x,y,r;
	int i,j,k;
	for(int k=0;k<n;k++){
		cin>>x>>y>>r;
		x=x+1000,y=y+1000;
		for(i=xa;i<=xb;i++){
			j=ya;
			if((i-x)*(i-x)+(j-y)*(j-y)<=r*r)  a[i][j]=0;
			j=yb;
			if((i-x)*(i-x)+(j-y)*(j-y)<=r*r)  a[i][j]=0;
		}
		for(i=ya+1;i<=yb-1;i++){
			j=xa;
			if((j-x)*(j-x)+(i-y)*(i-y)<=r*r)  a[j][i]=0;
			j=xb;
			if((j-x)*(j-x)+(i-y)*(i-y)<=r*r)  a[j][i]=0;
		}
	}
	for(i=xa;i<=xb;i++){
		for(j=ya;j<=yb;j++){
			if(a[i][j]==1)  sum2++;
		}
	}
	cout<<sum2<<"\n";
}


//    >File Name: 103B.cpp
//    > Author: Webwei

#include<iostream>
#include<algorithm>
using namespace std;
int a[2005][2005];
int main()
{
	int sum1=0,sum2=0;
	int xa,xb,ya,yb;
	cin>>xa>>ya>>xb>>yb;
	xa=xa+1000,ya=ya+1000,xb=xb+1000,yb=yb+1000;
	if(xa>xb) swap(xa,xb);
	if(ya>yb) swap(ya,yb);
	for(int i=xa;i<=xb;i++){
		for(int j=ya;j<=yb;j++){
			a[i][j]=1;
		}
	}
	for(int i=xa+1;i<=xb-1;i++){
		for(int j=ya+1;j<=yb-1;j++){
			a[i][j]=0;
		}
	}
	int n;
	cin>>n;
	int x,y,r;
	for(int i=0;i<n;i++){
		cin>>x>>y>>r;
		x=x+1000,y=y+1000;
		for(int i=xa;i<=xb;i++){
			for(int j=ya;j<=yb;j++){
				if(a[i][j]==1){
					if((i-x)*(i-x)+(j-y)*(j-y)<=r*r)  a[i][j]=0;
				}
			}
		}
	}
	for(int i=xa;i<=xb;i++){
		for(int j=ya;j<=yb;j++){
			if(a[i][j]==1)  sum2++;
		}
	}
	cout<<sum2<<endl;
}


#include <iostream>
#include <vector>

using namespace std;

// always declare big array here it's safer for stack than inside of main

vector < int > xpos , ypos , r;
int n;

int dist(int x1 , int y1 , int x2 , int y2){
    return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}

bool check(int x , int y){

    for(int i = 0 ; i < n ; i++)
        if(dist(x , y , xpos[i] , ypos[i]) <= r[i] * r[i])
            return 0;

    return 1;
}

int main(){

         // elements before me is (i - 1) * m + m - 1

         //  freopen("input.txt","r",stdin);
         //  freopen("output.txt","w",stdout);

         ios_base::sync_with_stdio(false);
         cin.tie(NULL);
         cout.tie(NULL);

         int x1 , y1 , x2 , y2 , cnt = 0;
         cin >> x1 >> y1 >> x2 >> y2 >> n;

         xpos.reserve(n);
         ypos.reserve(n);
         r.reserve(n);

         for(int i = 0 ; i < n ; i++)
            cin >> xpos[i] >> ypos[i] >> r;

         for(int i = min(x1 , x2) ; i <= max(x1 , x2) ; i++){
                cnt += check(i , y1) + check(i , y2);
         }

         for(int i = min(y1 , y2) + 1 ; i < max(y1 , y2) ; i++){
                cnt += check(x1 , i) + check(x2 , i);
         }

         cout << cnt;

    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

// always declare big array here it's safer for stack than inside of main

vector < int > xpos , ypos , r;
int n;

int dist(int x1 , int y1 , int x2 , int y2){
    return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}

bool check(int x , int y){

    for(int i = 0 ; i < n ; i++)
        if(dist(x , y , xpos[i] , ypos[i]) <= r[i] * r[i])
            return 0;

    return 1;
}

int main(){

         // elements before me is (i - 1) * m + m - 1

         //  freopen("input.txt","r",stdin);
         //  freopen("output.txt","w",stdout);

         //  ios_base::sync_with_stdio(false);
         //  cin.tie(NULL);
         //  cout.tie(NULL);

         int x1 , y1 , x2 , y2 , cnt = 0;
         scanf("%d%d%d%d%d" , &x1 , &y1 , &x2 , &y2 , &n);

         xpos.reserve(n);
         ypos.reserve(n);
         r.reserve(n);

         for(int i = 0 ; i < n ; i++)
            scanf("%d%d%d" , &xpos[i] , &ypos[i] , &r[i]);

         for(int i = min(x1 , x2) ; i <= max(x1 , x2) ; i++){
                cnt += check(i , y1) + check(i , y2);
         }

         for(int i = min(y1 , y2) + 1 ; i < max(y1 , y2) ; i++){
                cnt += check(x1 , i) + check(x2 , i);
         }

         printf("%d" , cnt);

    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

// always declare big array here it's safer for stack than inside of main

vector < int > xpos , ypos , r;
int n;

int dist(int x1 , int y1 , int x2 , int y2){
    return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}

bool check(int x , int y){

    for(int i = 0 ; i < n ; i++)
        if(dist(x , y , xpos[i] , ypos[i]) <= r[i] * r[i])
            return 0;

    return 1;
}

int main(){

         // elements before me is (i - 1) * m + m - 1

         //  freopen("input.txt","r",stdin);
         //  freopen("output.txt","w",stdout);

         ios_base::sync_with_stdio(false);
         cin.tie(NULL);
         cout.tie(NULL);

         int x1 , y1 , x2 , y2 , cnt = 0;
         cin >> x1 >> y1 >> x2 >> y2 >> n;

         xpos.reserve(n);
         ypos.reserve(n);
         r.reserve(n);

         for(int i = 0 ; i < n ; i++)
            cin >> xpos[i] >> ypos[i] >> r[i];

         for(int i = min(x1 , x2) ; i <= max(x1 , x2) ; i++){
                cnt += check(i , y1) + check(i , y2);
         }

         for(int i = min(y1 , y2) + 1 ; i < max(y1 , y2) ; i++){
                cnt += check(x1 , i) + check(x2 , i);
         }

         cout << cnt;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int , int> ii;
int n;
pair< pair<int , int >, double> arr[1010];
double dis(int x1, int x2, int y1, int y2){
	return sqrt(((x1-x2)*(x1-x2))+ ((y1-y2)*(y1-y2)));
}
bool che(int x, int y){
	for(int i = 0; i < n; i++){
		double dist = dis(x,arr[i].first.first,y,arr[i].first.second);
		if(dist <= arr[i].second)
			return true;
	}
	return false;
}
int main() {
	int xa , ya , xb, yb, xx, yy;
	double zz;
	cin >> xa >> ya >> xb >> yb;
	int x1 = min(xa, xb);
	int x2 = max(xa, xb);
	int y1 = min(ya, yb);
	int y2 = max(ya, yb);
	int ret = 0;
	cin >> n;
	for(int i = 0 ;i < n;i++){
		cin >> xx >> yy >>zz;
		ii b = ii(xx,yy);
		arr[i].first = b;
		arr[i].second = zz;
	}
	for(int i = x1 ; i <= x2;i++){
		if(!che(i,y2))
			ret++;
	}
	for(int i = y1 ;i< y2;i++){
		if(!che(x1,i))
			ret++;
		if(!che(x2,i))
			ret++;
	}
	cout << ret << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int , int> ii;
int n;
pair< pair<int , int >, double> arr[1010];
double dis(int x1, int x2, int y1, int y2){
	return ((x1-x2)*(x1-x2))+ ((y1-y2)*(y1-y2));
}
bool che(int x, int y){
	for(int i = 0; i < n; i++){
		double dist = dis(x,arr[i].first.first,y,arr[i].first.second);
		if(dist <= arr[i].second * arr[i].second)
			return true;
	}
	return false;
}
int main() {
	int xa , ya , xb, yb, xx, yy;
	double zz;
	cin >> xa >> ya >> xb >> yb;
	int x1 = min(xa, xb);
	int x2 = max(xa, xb);
	int y1 = min(ya, yb);
	int y2 = max(ya, yb);
	int ret = 0;
	cin >> n;
	for(int i = 0 ;i < n;i++){
		cin >> xx >> yy >>zz;
		ii b = ii(xx,yy);
		arr[i].first = b;
		arr[i].second = zz;
	}
	for(int i = x1 ; i <= x2;i++){
		if(!che(i,y2))
			ret++;
		if(!che(i,y1))
			ret++;
	}
	for(int i = y1 + 1 ;i< y2;i++){
		if(!che(x1,i))
			ret++;
		if(!che(x2,i))
			ret++;
	}
	cout << ret << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define cr(x) cout<<#x<<"= "<<x<<"\n"
#define F first
#define S second
#define X first
#define Y second.first
#define Z second.second
#define pb push_back
#define mp make_pair
#define SWS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define double long double
#define ashar(a) fixed<<setprecision((a))
#define endl "\n"
#define int long long

typedef long long ll;
typedef pair <int, int > pii;
typedef vector <int> vi;

const int INFll = 1000000000000000000ll, INF = 0x3f3f3f3f, DOM = (1000 * 1000 * 1000 + 7);
const double EPS = 1e-8;

const int MAXN = 1000 + 5;

bool mark[MAXN];
vector <pii> a;
int n, xa, xb, ya, yb;

int32_t main()
{
	cin>>xa>>ya>>xb>>yb;
	if(xa>xb) swap(xa, xb), swap(ya, yb);
	for(int i=xa+1;i<xb;i++) a.pb(pii(i, ya)), a.pb(pii(i, yb));
	if(ya>yb) for(int i=ya;i>=yb;i--) a.pb(pii(xb, i)), a.pb(pii(xa, i));
	else for(int i=ya;i<=yb;i++) a.pb(pii(xb, i)), a.pb(pii(xa, i));
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x, y, r;
		cin>>x>>y>>r;
		r*=r;
		for(int j=0;j<a.size();j++)
			if(!mark[j]&&((a[j].F-x)*(a[j].F-x))+((a[j].S-y)*(a[j].S-y))<=r) mark[j]=1;
	}
	int ans=0;
	for(int i=0;i<a.size();i++) if(!mark[i]) ans++;
	return cout<<ans<<endl, 0;
}


#include <bits/stdc++.h>
using namespace std;

#define cr(x) cout<<#x<<"= "<<x<<"\n"
#define F first
#define S second
#define X first
#define Y second.first
#define Z second.second
#define pb push_back
#define mp make_pair
#define SWS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define double long double
#define ashar(a) fixed<<setprecision((a))
#define endl "\n"
#define int long long

typedef long long ll;
typedef pair <int, int > pii;
typedef vector <int> vi;

const int INFll = 1000000000000000000ll, INF = 0x3f3f3f3f, DOM = (1000 * 1000 * 1000 + 7);
const double EPS = 1e-8;

const int MAXN = 1000 * 100 + 100;

bool mark[MAXN];
vector <pii> a;
int n, xa, xb, ya, yb;

int32_t main()
{
	cin>>xa>>ya>>xb>>yb;
	if(xa>xb) swap(xa, xb), swap(ya, yb);
	for(int i=xa+1;i<xb;i++) a.pb(pii(i, ya)), a.pb(pii(i, yb));
	if(ya>yb) for(int i=ya;i>=yb;i--) a.pb(pii(xb, i)), a.pb(pii(xa, i));
	else for(int i=ya;i<=yb;i++) a.pb(pii(xb, i)), a.pb(pii(xa, i));
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x, y, r;
		cin>>x>>y>>r;
		r*=r;
		for(int j=0;j<a.size();j++)
			if(!mark[j]&&((a[j].F-x)*(a[j].F-x))+((a[j].S-y)*(a[j].S-y))<=r) mark[j]=1;
	}
	int ans=0;
	for(int i=0;i<a.size();i++) if(!mark[i]) ans++;
	return cout<<ans<<endl, 0;
}


#include <iostream>
#include <fstream>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define fi "B.inp" //div2-108
#define fo "B.out"
#define maxi 2147483647

using namespace std;

int n,dai,dem,vt,ck,max1,min1,kq,tong;
int xa,ya,xb,yb;
int x[1111],y[1111],r[1111];

int tinh(int q,int w)
{
    int i;

    for(i=0;i<n;i++)
    {
    	if((q-x[i])*(q-x[i])+(w-y[i])*(w-y[i])<=r[i]*r[i])
            return 0;
    }

    return 1;
}

void sol()
{
	int i,j;

    if(xa>xb)
    {
    	j=xa;
    	xa=xb;
    	xb=j;
    }

    if(ya>yb)
    {
    	j=ya;
    	ya=yb;
    	yb=j;
    }

    dem=0;
    for(i=xa;i<=xb;i++)
    {
    	dem=dem+tinh(i,xa)+tinh(i,xb);
    }

    for(i=ya;i<=yb;i++)
    {
    	dem=dem+tinh(ya,i)+tinh(yb,i);
    }

    cout<<dem<<endl;
}

int main()
{
	int i,j;

//	freopen(fi,"r",stdin);
//	freopen(fo,"w",stdout);

	while(scanf("%d %d %d %d %d",&xa,&ya,&xb,&yb,&n)>0)
	{
		for(i=0;i<n;i++)
			scanf("%d %d %d",&x[i],&y[i],&r[i]);

		sol();
	}

	return 0;
}


#include <iostream>
#include <fstream>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define fi "B.inp" //div2-108
#define fo "B.out"
#define maxi 2147483647

using namespace std;

int n,dai,dem,vt,ck,max1,min1,kq,tong;
int xa,ya,xb,yb;
int x[1111],y[1111],r[1111];

int tinh(int q,int w)
{
    int i;

    for(i=0;i<n;i++)
    {
    	if((q-x[i])*(q-x[i])+(w-y[i])*(w-y[i])<=r[i]*r[i])
            return 0;
    }

    return 1;
}

void sol()
{
	int i,j;

    if(xa>xb)
    {
    	j=xa;
    	xa=xb;
    	xb=j;
    }

    if(ya>yb)
    {
    	j=ya;
    	ya=yb;
    	yb=j;
    }

    dem=0;
    for(i=xa;i<=xb;i++)
    {
    	dem=dem+tinh(i,ya)+tinh(i,yb);
    }

    for(i=ya+1;i<yb;i++)
    {
    	dem=dem+tinh(xa,i)+tinh(xb,i);
    }

    cout<<dem<<endl;
}

int main()
{
	int i,j;

//	freopen(fi,"r",stdin);
//	freopen(fo,"w",stdout);

	while(scanf("%d %d %d %d %d",&xa,&ya,&xb,&yb,&n)>0)
	{
		for(i=0;i<n;i++)
			scanf("%d %d %d",&x[i],&y[i],&r[i]);

		sol();
	}

	return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#define N 1020
#define M 6020
using namespace std;

int xa, ya, xb, yb;
int x[N], y[N], r[N];

int main(void)
{
    int n;
    int i, j, k;
    bool f;
    int o;

    scanf("%d %d %d %d", &xa, &ya, &xb, &yb);
    if(xb < xa)
        swap(xa, xb);
    if(yb < ya)
        swap(ya, yb);

    scanf("%d", &n);
    for(i = 0; i < n; i ++)
        scanf("%d %d %d", &x[i], &y[i], &r[i]);

    for(i = xa, o = 0; i <= xb; i ++)
        for(j = ya; j <= yb; j ++)
            if((((i == ya || i == yb) && (xa <= j && j <= xb)) || ((ya <= i && i <= yb) && (j == xa || j == xb))))
            {
                for(k = 0, f = false; k < n && !f; k ++)
                    if((i - x[k]) * (i - x[k]) + (j - y[k]) * (j - y[k]) <= r[k] * r[k])
                        f = true;
                o += !f;
            }

    printf("%d\n", o);

    return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#define N 1020
#define M 6020
using namespace std;

int xa, ya, xb, yb;
int x[N], y[N], r[N];

int main(void)
{
    int n;
    int i, j, k;
    bool f;
    int o;

    scanf("%d %d %d %d", &xa, &ya, &xb, &yb);
    if(xb < xa)
        swap(xa, xb);
    if(yb < ya)
        swap(ya, yb);

    scanf("%d", &n);
    for(i = 0; i < n; i ++)
        scanf("%d %d %d", &x[i], &y[i], &r[i]);

    for(i = xa, o = 0; i <= xb; i ++)
        for(j = ya; j <= yb; j ++)
            if((((i == xa || i == xb) && (ya <= j && j <= yb)) || ((xa <= i && i <= xb) && (j == ya || j == yb))))
            {
                for(k = 0, f = false; k < n && !f; k ++)
                    if((i - x[k]) * (i - x[k]) + (j - y[k]) * (j - y[k]) <= r[k] * r[k])
                        f = true;
                // if(!f)
                //     printf("%d %d\n", i, j);
                o += !f;
            }

    printf("%d\n", o);

    return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#define N 1020
#define M 2020
using namespace std;

int xa, ya, xb, yb;
int x[N], y[N], r[N];
int f[M][M], g[M][M];

void debug_output(void)
{
    int i, j;

    for(i = 1000; i <= 1007; i ++)
    {
        for(j = 1000; j <= 1007; j ++)
        {
            g[i][j] = g[i][j - 1] + f[i][j];
            printf("%d ", g[i][j]);
        }
        putchar('\n');
    }
    putchar('\n');

    return;
}

int main(void)
{
    int n;
    int i, j;
    double l;
    int o;

    scanf("%d %d %d %d", &xa, &ya, &xb, &yb);
    xa += 1001;
    ya += 1001;
    xb += 1001;
    yb += 1001;
    if(xb < xa)
        swap(xa, xb);
    if(yb < ya)
        swap(ya, yb);

    scanf("%d", &n);
    for(i = 0; i < n; i ++)
    {
        scanf("%d %d %d", &x[i], &y[i], &r[i]);
        x[i] += 1001;
        y[i] += 1001;

        ++ f[y[i]][x[i] - r[i]];
        -- f[y[i]][x[i] + r[i] + 1];
        for(j = 1; j <= r[i]; j ++)
        {
            l = sqrt(r[i] * r[i] - j * j);
            // printf("%.4lf %d\n", l, ceil(x[i] - l));
            ++ f[y[i] - j][(int)ceil(x[i] - l)];
            -- f[y[i] - j][(int)floor(x[i] + l) + 1];
            ++ f[y[i] + j][(int)ceil(x[i] - l)];
            -- f[y[i] + j][(int)floor(x[i] + l) + 1];
        }
        // putchar('\n');

        // debug_output();
    }

    for(i = ya, o = 0; i <= yb; i ++)
    {
        for(j = xa; j <= xb; j ++)
        {
            f[i][j] += f[i][j - 1];
            o += !f[i][j];
            // printf("%d ", f[i][j]);
        }
        // putchar('\n');
    }

    printf("%d\n", o);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

# define FORN( a , b , c ) for ( int a = b ; a <= c ; ++ a )
# define FORNBACK( a , b , c ) for ( int a = b ; a >= c ; -- a )

struct plm {
    int x , y , r ;
    void sett ( int a , int b , int c )
    {
        x = a ;
        y = b ;
        r = c ;
    }
};

plm specials [ 100011 ] ;

struct points {
    int x , y ;
    void sett ( int a , int b )
    {
        x = a ;
        y = b ;
    }
};

points q [ 100000 ] ;

bitset < 100000 > viz ;

int main ( void )
{
    ios :: sync_with_stdio ( false ) ;
    //freopen ( "input" , "r" , stdin ) ;
    //freopen ( "output" , "w" , stdout ) ;
    int xs , ys , xf , yf ;
    cin >> xs >> ys >> xf >> yf ;
    int n ;
    cin >> n ;
    FORN ( i , 1 , n )
    {
        int x , y , r ;
        cin >> x >> y >> r ;
        specials [ i ].sett ( x , y , r ) ;
    }
    if ( xs > xf )
        swap ( xs , xf ) ;
    if ( ys > yf )
        swap ( ys , yf ) ;
    int e = 0 ;
    FORN ( i , xs , xf )
    {
        ++ e ;
        q [ e ].sett ( i , yf ) ;
        ++ e ;
        q [ e ].sett ( i , ys ) ;
    }
    FORN ( i , ys + 1 , yf - 1 )
    {
        ++ e ;
        q [ e ].sett ( xs , i ) ;
        ++ e ;
        q [ e ].sett ( xf , i ) ;
    }
    FORN ( i , 1 , e )
    {
        FORN ( j , 1 , n )
        {
            long long rr = 1LL * specials [ j ].r * specials [ j ].r ;
            long long xx = 1LL * ( specials [ j ].x - q [ i ].x ) * ( specials [ j ].x - q [ i ].x ) ;
            long long yy = 1LL * ( specials [ j ].y - q [ i ].y ) * ( specials [ j ].y - q [ i ].y ) ;
            if ( xx + yy <= rr ){
                viz [ i ] = 1 ;
                break ;
            }
        }
    }
    int CET = 0 ;
    FORN ( i , 1 , e )
        if ( viz [ i ] == 0 )
            ++ CET ;
    cout << CET << '\n' ;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

# define FORN( a , b , c ) for ( int a = b ; a <= c ; ++ a )
# define FORNBACK( a , b , c ) for ( int a = b ; a >= c ; -- a )

struct plm {
    int x , y , r ;
    void sett ( int a , int b , int c )
    {
        x = a ;
        y = b ;
        r = c ;
    }
};

plm specials [ 100011 ] ;

struct points {
    int x , y ;
    void sett ( int a , int b )
    {
        x = a ;
        y = b ;
    }
};

points q [ 100000 ] ;

bitset < 100000 > viz ;

int main ( void )
{
    ios :: sync_with_stdio ( false ) ;
    //freopen ( "input" , "r" , stdin ) ;
    //freopen ( "output" , "w" , stdout ) ;
    int xs , ys , xf , yf ;
    cin >> xs >> ys >> xf >> yf ;
    int n ;
    cin >> n ;
    FORN ( i , 1 , n )
    {
        int x , y , r ;
        cin >> x >> y >> r ;
        specials [ i ].sett ( x , y , r ) ;
    }
    if ( xs > xf )
        swap ( xs , xf ) ;
    if ( ys > yf )
        swap ( ys , yf ) ;
    int e = 0 ;
    FORN ( i , xs , xf )
    {
        ++ e ;
        q [ e ].sett ( i , yf ) ;
        ++ e ;
        q [ e ].sett ( i , ys ) ;
    }
    FORN ( i , ys + 1 , yf - 1 )
    {
        ++ e ;
        q [ e ].sett ( xs , i ) ;
        q [ e ].sett ( xf , i ) ;
    }
    FORN ( i , 1 , e )
    {
        FORN ( j , 1 , n )
        {
            long long rr = 1LL * specials [ j ].r * specials [ j ].r ;
            long long xx = 1LL * ( specials [ j ].x - q [ i ].x ) * ( specials [ j ].x - q [ i ].x ) ;
            long long yy = 1LL * ( specials [ j ].y - q [ i ].y ) * ( specials [ j ].y - q [ i ].y ) ;
            if ( xx + yy <= rr ){
                viz [ i ] = 1 ;
                break ;
            }
        }
    }
    int CET = 0 ;
    FORN ( i , 1 , e )
        if ( viz [ i ] == 0 )
            ++ CET ;
    cout << CET << '\n' ;
    return 0;
}


#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <float.h>

using namespace std;

#define REP(i, from, to) for (int i = (from); i < (to); ++i)
#define FOR(i, n) REP(i, 0, (n))
#define ALL(x) x.begin(), x.end()
#define SIZE(x) (int)x.size()
#define PB push_back
#define MP make_pair

typedef long long i64;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef pair<int, int> PII;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(false);

    int xa, ya, xb, yb;
    cin >> xa >> ya >> xb >> yb;

    int x1 = min(xa, xb), x2 = max(xa, xb);
    int y1 = min(ya, yb), y2 = max(ya, yb);

    int n = 0;
    cin >> n;

    VI x(n), y(n), r(n);
    FOR (i, n) {
        cin >> x[i] >> y[i] >> r[i];
    }

    set<PII> res;
    REP (x_, x1, x2 + 1) {
        bool ok1 = true, ok2 = true;
        FOR (i, n) {
            ok1 |= pow(x[i] - x_, 2.0) + pow(y[i] - y1, 2.0) <= r[i] * r[i];
            ok2 |= pow(x[i] - x_, 2.0) + pow(y[i] - y2, 2.0) <= r[i] * r[i];
        }

        if (ok1)
            res.insert(MP(x_, y1));
        if (ok2)
            res.insert(MP(x_, y2));
    }

    REP (y_, y1, y2 + 1) {
        bool ok1 = true, ok2 = true;
        FOR (i, n) {
            ok1 |= pow(x[i] - x1, 2.0) + pow(y[i] - y_, 2.0) <= r[i] * r[i];
            ok2 |= pow(x[i] - x2, 2.0) + pow(y[i] - y_, 2.0) <= r[i] * r[i];
        }

        if (ok1)
            res.insert(MP(x1, y_));
        if (ok2)
            res.insert(MP(x2, y_));
    }

    cout << SIZE(res) << endl;

    return 0;
}


#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <float.h>

using namespace std;

#define REP(i, from, to) for (int i = (from); i < (to); ++i)
#define FOR(i, n) REP(i, 0, (n))
#define ALL(x) x.begin(), x.end()
#define SIZE(x) (int)x.size()
#define PB push_back
#define MP make_pair

typedef long long i64;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef pair<int, int> PII;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(false);

    int xa, ya, xb, yb;
    cin >> xa >> ya >> xb >> yb;

    int x1 = min(xa, xb), x2 = max(xa, xb);
    int y1 = min(ya, yb), y2 = max(ya, yb);

    int n = 0;
    cin >> n;

    VI x(n), y(n), r(n);
    FOR (i, n) {
        cin >> x[i] >> y[i] >> r[i];
    }

    set<PII> res;
    REP (x_, x1, x2 + 1) {
        bool ok1 = false, ok2 = false;
        FOR (i, n) {
            ok1 |= pow(x[i] - x_, 2.0) + pow(y[i] - y1, 2.0) <= r[i] * r[i];
            ok2 |= pow(x[i] - x_, 2.0) + pow(y[i] - y2, 2.0) <= r[i] * r[i];
        }

        if (!ok1)
            res.insert(MP(x_, y1));
        if (!ok2)
            res.insert(MP(x_, y2));
    }

    REP (y_, y1, y2 + 1) {
        bool ok1 = false, ok2 = false;
        FOR (i, n) {
            ok1 |= pow(x[i] - x1, 2.0) + pow(y[i] - y_, 2.0) <= r[i] * r[i];
            ok2 |= pow(x[i] - x2, 2.0) + pow(y[i] - y_, 2.0) <= r[i] * r[i];
        }

        if (!ok1)
            res.insert(MP(x1, y_));
        if (!ok2)
            res.insert(MP(x2, y_));
    }

    cout << SIZE(res) << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int dist (int x1, int y1, int x2, int y2){
	double x = pow(abs (x2-x1),2) + pow (abs(y1-y2),2);
	return x;
}

int main(){
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int lattice; //= 2*(x2-x1) + 2 * (y1-y2-2);

	vector <pair <int, int>> spots;
	for (int i = x1; i <= x2; i++) {
		spots.push_back ({i, y1}); //atas;
		spots.push_back ({i, y2}); //bawah;
		//lattice += 2;
	}

	for (int i = y2+1; i < y1; i++){
		spots.push_back ({x1, i});
		spots.push_back ({x2, i});
		//lattice += 2;
	}

	lattice = spots.size();

	int n;
	int dingin = 0;

	cin >> n;
	for (int i = 0; i < n; i++){
		int x, y , r;
		cin >> x >> y >> r;

		for (int j = 0; j < lattice; j++){
			if (spots[j].first != -1) {
				if (dist(spots[j].first, spots[j].second, x, y) <= r*r) {

					spots[j].first = -1;
					spots[j].second = -1;
				}
			}
		}
	}

	for (int i = 0; i < lattice; i++){
		if (spots[i].first != -1) dingin ++;
	}
	cout << dingin << endl;
}


#include <bits/stdc++.h>
using namespace std;

int dist (int x1, int y1, int x2, int y2){
	double x = pow(abs (x2-x1),2) + pow (abs(y1-y2),2);
	return x;
}

int main(){
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int lattice; //= 2*(x2-x1) + 2 * (y1-y2-2);

	vector <pair <int, int>> spots;
	for (int i = x1; i <= x2; i++) {
		spots.push_back ({i, y1}); //atas;
		spots.push_back ({i, y2}); //bawah;
		//lattice += 2;
	}

	for (int i = y2+1; i < y1; i++){
		spots.push_back ({x1, i});
		spots.push_back ({x2, i});
		//lattice += 2;
	}

	lattice = spots.size();

	int n;
	int dingin = 0;

	cin >> n;
	for (int i = 0; i < n; i++){
		int x, y , r;
		cin >> x >> y >> r;

		for (int j = 0; j < lattice; j++){
			if (spots[j].first != -260620001) {
				if (dist(spots[j].first, spots[j].second, x, y) <= r*r) {
					spots[j].first = -260620001;
					spots[j].second = -260620001;
				}
			}
		}
	}

	for (int i = 0; i < lattice; i++){
		if (spots[i].first != -260620001) dingin ++;
	}
	cout << dingin << endl;
}


#include <bits/stdc++.h>
using namespace std;

int dist (int x1, int y1, int x2, int y2){
	double x = pow(abs (x2-x1),2) + pow (abs(y1-y2),2);
	return x;
}

int main(){
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int lattice; //= 2*(x2-x1) + 2 * (y1-y2-2);

	if (x1 > x2 ) swap (x2, x1);
	if (y1 < y2) swap (y2, y1);

	vector <pair <int, int>> spots;
	for (int i = x1; i <= x2; i++) {
//		cout << i << " " << y1 << endl;
//		cout << i << " " << y2 << endl;
		spots.push_back ({i, y1}); //atas;
		spots.push_back ({i, y2}); //bawah;
		//lattice += 2;
	}

	for (int i = y2+1; i < y1; i++){
//		cout << x1 << " " << i << endl;
//		cout << x2 << " " << i << endl;
		spots.push_back ({x1, i});
		spots.push_back ({x2, i});
		//lattice += 2;
	}

	lattice = spots.size();

	int n;
	int dingin = 0;

	cin >> n;
	for (int i = 0; i < n; i++){
		int x, y , r;
		cin >> x >> y >> r;

		for (int j = 0; j < lattice; j++){
			if (spots[j].first != -2606200) {
				//cout << spots[j].first << " " << spots[j].second << endl;
				if (dist(spots[j].first, spots[j].second, x, y) <= r*r) {
//					cout << "masuk ga si?" << endl;
//					cout << sqrt(dist(spots[j].first, spots[j].second, x, y)) << endl;
					spots[j].first = -2606200;
					spots[j].second = -2606200;
				}
			}
		}
	}

	for (int i = 0; i < lattice; i++){
		if (spots[i].first != -2606200) dingin ++;
	}
	cout << dingin << endl;
}


#include <stdio.h>
#include <iostream>
using namespace std;
#include <sstream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <iomanip>
#include <stack>

typedef long long ll;
typedef long double ld;

void swp(int &a,int &b)
{
    int temp=a;
    a=b;
    b=temp;
}

int main()
{
     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     int x1,y1,x2,y2,counter=0,heaters;
     int points[1005][2];
     cin>>x1>>y1>>x2>>y2>>heaters;
     if (x1>x2) swp(x1,x2);
     if (y1>y2) swp(y1,y2);
     int arr[heaters+1][3],ind=0;
     for (int i=0;i<heaters;i++)
     {
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
     }
     for (int i=x1;i<=x2;i++)
     {
        points[ind][0]=i;
        points[ind][1]=y1;
        ind++;
        points[ind][0]=i;
        points[ind][1]=y2;
        ind++;
     }
     for (int i=y1+1;i<y2;i++)
     {
        points[ind][0]=x1;
        points[ind][1]=i;
        ind++;
        points[ind][0]=x2;
        points[ind][1]=i;
        ind++;
     }
     for (int i=0;i<ind;i++)
     {
        for (int u=0;u<heaters;u++)
        {
            if (((points[i][0]-arr[u][0])*(points[i][0]-arr[u][0]))+((points[i][1]-arr[u][1])*(points[i][1]-arr[u][1]))<=arr[u][2]*arr[u][2])
            {
               // cout<<points[i][0]<<","<<points[i][1]<<"\n";
               // cout<<arr[u][0]<<","<<arr[u][1]<<" "<<arr[u][2]<<"\n";
                counter++;
                break;
            }
        }
     }
     cout<<ind-counter<<endl;
     return 0;
}


#include <stdio.h>
#include <iostream>
using namespace std;
#include <sstream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <iomanip>
#include <stack>

typedef long long ll;
typedef long double ld;

void swp(int &a,int &b)
{
    int temp=a;
    a=b;
    b=temp;
}

int main()
{
     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     int x1,y1,x2,y2,counter=0,heaters;
     ll points[1001][2];
     cin>>x1>>y1>>x2>>y2>>heaters;
     if (x1>x2) swp(x1,x2);
     if (y1>y2) swp(y1,y2);
     int arr[heaters+1][3],ind=0;
     for (int i=0;i<heaters;i++)
     {
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
     }
     for (int i=x1;i<=x2;i++)
     {
        points[ind][0]=i;
        points[ind][1]=y1;
        ind++;
        points[ind][0]=i;
        points[ind][1]=y2;
        ind++;
     }
     for (int i=y1+1;i<y2;i++)
     {
        points[ind][0]=x1;
        points[ind][1]=i;
        ind++;
        points[ind][0]=x2;
        points[ind][1]=i;
        ind++;
     }
     for (int i=0;i<ind;i++)
     {
        for (int u=0;u<heaters;u++)
        {
            if (((points[i][0]-arr[u][0])*(points[i][0]-arr[u][0]))+((points[i][1]-arr[u][1])*(points[i][1]-arr[u][1]))<=arr[u][2]*arr[u][2])
            {
                counter++;
                break;
            }
        }
     }
     cout<<ind-counter<<endl;
     return 0;
}


#include <stdio.h>
#include <iostream>
using namespace std;
#include <sstream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <iomanip>
#include <stack>

typedef long long ll;
typedef long double ld;

int main()
{
     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     int x1,y1,x2,y2,one=0,two=0,heaters,x,y,r;
     vector<pair<int,int> > pos;
     cin>>x1>>y1>>x2>>y2;
     one=max(x1,x2)-min(x1,x2);
     two=max(y1,y2)-min(y1,y2);
     vector<pair<int,int> > points;
     for (int i=1;i<two;i++) points.push_back({x1,min(y1,y2)+i}),points.push_back({x2,min(y1,y2)+i});
     for (int i=0;i<=one;i++) points.push_back({i+min(x1,x2),y1}),points.push_back({i+min(x1,x2),y2});
     int counter=points.size();
     cin>>heaters;
     for (int i=0;i<heaters;i++)
     {
        cin>>x>>y>>r;
        for (int u=0;u<points.size();u++)
        {
            //cout<<points[u].first<<" "<<points[u].second<<endl;
            if(sqrt(((pow(abs(points[u].first-x),2)+(pow(abs(points[u].second-y),2)))))<=r)
            {
                counter--;
                points.erase(points.begin()+u);
            }
            //cout<<points[u].first<<" "<<points[u].second<<endl;
        }
     }
     cout<<counter-1<<endl;
     return 0;
}


#include <stdio.h>
#include <iostream>
using namespace std;
#include <sstream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <iomanip>
#include <stack>

typedef long long ll;
typedef long double ld;

void swp(int &a,int &b)
{
    int temp=a;
    a=b;
    b=temp;
}

int main()
{
     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     int x1,y1,x2,y2,counter=0,heaters;
     cin>>x1>>y1>>x2>>y2>>heaters;
     if (x1>x2) swp(x1,x2);
     if (y1>y2) swp(y1,y2);
     int arr[heaters+1][3],ind=0;
     for (int i=0;i<heaters;i++)
     {
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
     }
     for (int i=x1;i<=x2;i++)
     {
        int a=1,b=1;
            for(int u=0;u<heaters;u++)
            {
                if ((i-arr[u][0])*(i-arr[u][0])+(y1-arr[u][1])*(y1-arr[u][1])<=arr[u][2]*arr[u][2]) a=0;
                if ((i-arr[u][0])*(i-arr[u][0])+(y2-arr[u][1])*(y2-arr[u][1])<=arr[u][2]*arr[u][2]) b=0;
            }
            counter+=a+b;
     }
     for (int i=y1+1;i<y2;i++)
     {
        int a=1,b=1;
            for(int u=0;u<heaters;u++)
            {
                if ((x1-arr[u][0])*(x1-arr[u][0])+(i-arr[u][1])*(i-arr[u][1])<=arr[u][2]*arr[u][2]) a=0;
                if ((x2-arr[u][0])*(x2-arr[u][0])+(i-arr[u][1])*(i-arr[u][1])<=arr[u][2]*arr[u][2]) b=0;
            }
            counter+=a+b;
     }
     cout<<counter<<endl;
     return 0;
}


#include <iostream>
#include <cmath>
using namespace std;

int main()
{
int arr[1000][3]={0};
int n=0;
int xa=0,ya=0,xb=0,yb=0;
cin>>xa>>ya;
cin>>xb>>yb;
cin>>n;
for(int i=0;i<n;i++){
    cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
}
int ans=0;
for(int i=min(xa,xb),j=max(xa,xb);i<=j;i++){
    bool warm1=0,warm2=0;
for(int z=0;z<n;z++){
double d1=sqrt(pow(i-arr[z][0],2)+pow(ya-arr[z][1],2));
double d2=sqrt(pow(i-arr[z][0],2)+pow(yb-arr[z][1],2));
if(d1<=arr[z][2]){warm1=1;}
if(d2<=arr[z][2]){warm2=1;}
}
if(!warm1){ans++;}
if(!warm2){ans++;}

}
for(int i=min(ya,yb)+1,j=max(ya,yb);i<j;i++){
    bool warm1=0,warm2=0;
for(int z=0;z<n;z++){
double d1=sqrt(pow(xa-arr[z][0],2)+pow(i-arr[z][1],2));
double d2=sqrt(pow(xb-arr[z][0],2)+pow(i-arr[z][1],2));
if(d1<=(arr[z][2]*1.0)){warm1=1;}
if(d2<=(arr[z][2]*1.0)){warm2=1;}
}
if(!warm1){ans++;}
if(!warm2){ans++;}

}

cout<<ans;

    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;

int main()
{
int arr[1000][3]={0};
int n=0;
int xa=0,ya=0,xb=0,yb=0;
cin>>xa>>ya;
cin>>xb>>yb;
cin>>n;
for(int i=0;i<n;i++){
    cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
}
int ans=0;
for(int i=min(xa,xb),j=max(xa,xb);i<=j;i++){
    int blanket1=0,blanket2=0;
for(int z=0;z<n;z++){
int d1=sqrt(pow(i-arr[z][0],2)+pow(ya-arr[z][1],2));
int d2=sqrt(pow(i-arr[z][0],2)+pow(yb-arr[z][1],2));
if(d1>arr[z][2]){blanket1++;}
if(d2>arr[z][2]){blanket2++;}
}
if(blanket1==n-1){ans++;}
if(blanket2==n-1){ans++;}

}
for(int i=min(ya,yb)+1,j=max(ya,yb);i<j;i++){
    int blanket1=0,blanket2=0;
for(int z=0;z<n;z++){
int d1=sqrt(pow(xa-arr[z][0],2)+pow(i-arr[z][1],2));
int d2=sqrt(pow(xb-arr[z][0],2)+pow(i-arr[z][1],2));
if(d1>arr[z][2]){blanket1++;}
if(d2>arr[z][2]){blanket2++;}
}
if(blanket1==n-1){ans++;}
if(blanket2==n-1){ans++;}

}

cout<<ans;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool isClose(long x1,long y1,long x2,long y2,long r)
{
    if((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) <= r * r)
    {
        return 1;
    }
    return 0;
}

int main()
{
#ifndef ONLINE_JUDGE
     //freopen("c.in", "r", stdin);
#endif
  long xa(0), ya(0), xb(0), yb(0); scanf("%ld %ld %ld %ld", &xa, &ya, &xb, &yb);

    long xmin(0), xmax(0), ymin(0), ymax(0);
    if(xa < xb){xmin = xa; xmax = xb;} else{xmin = xb; xmax = xa;}
    if(ya < yb){ymin = ya; ymax = yb;} else{ymin = yb; ymax = ya;}

    std::set<std::pair<long,long>> coldGenerals;
    std::set<std::pair<long,long>>::iterator myIter;

    for(long k = ymin; k <= ymax; k++){coldGenerals.insert(std::pair<long,long>(xmin,k));}
    for(long k = ymin; k <= ymax; k++){coldGenerals.insert(std::pair<long,long>(xmax,k));}
    for(long k = xmin; k <= xmax; k++){coldGenerals.insert(std::pair<long,long>(k,ymin));}
    for(long k = xmin; k <= xmax; k++){coldGenerals.insert(std::pair<long,long>(k,ymax));}

    std::vector<std::pair<long,long>> radiators;
    std::vector<long> radii;

    long numRadiators(0); scanf("%ld", &numRadiators);

    for(long k = 0; k < numRadiators; k++){
        long xtemp(0), ytemp(0), tempRadius(0); scanf("%ld %ld %ld", &xtemp, &ytemp, &tempRadius);
        radiators.push_back(std::pair<long,long>(xtemp,ytemp));
        radii.push_back(tempRadius);
    }

    for(long k = 0; k < numRadiators; k++){
        myIter = coldGenerals.begin();
        while(myIter != coldGenerals.end()){
            if(isClose(myIter->first, myIter->second,radiators[k].first,radiators[k].second,radii[k])){coldGenerals.erase(myIter); myIter = coldGenerals.begin();}
            else{myIter++;}
        }
    }

    printf("%ld\n", coldGenerals.size());

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int distance(int x1 , int y1 , int x2 , int y2)
{
    x1 = (x1 - x2) ^ 2;
    y1 = (y1 - y2) ^ 2;
    return sqrt(x1 + x2);
}

bool inRange(int x1 , int y1 , int x2 , int y2 , int r)
{
    if(distance(x1 , y1 , x2 , y2) <= r)
        return true;
    return false;
}

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("c.in", "r", stdin);
#endif
    //vector<vector<pair<int,int>>>v;
    int x1 , y1 , x2 , y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int xmin , xmax , ymin , ymax;
    if(x1 > x2){
        xmax = x1;
        xmin = x2;
    }else{
        xmax = x2;
        xmin = x1;
    }

    if(y1 > y2){
        ymax = y1;
        ymin = y2;
    }else{
        ymax = y2;
        ymin = y1;
    }

    //formulate points of rect
    set<pair<int,int>> points;
    set<pair<int,int>>::iterator itr;
    for(int i = xmin ; i < xmax ; i++)
    {
        points.insert(pair<int,int>(i , ymin));
    }
    for(int i = xmin ; i < xmax ; i++)
    {
        points.insert(pair<int,int>(i , ymax));
    }
    for(int i = ymin ; i < ymax ; i++)
    {
        points.insert(pair<int,int>(xmin , i));
    }
    for(int i = ymin ; i < ymax ; i++)
    {
        points.insert(pair<int,int>(xmax , i));
    }

    vector<pair<int,int>> rpoints;
    vector<int>radius;
    int n;
    cin >> n;
    int counter = 0;
    while(n--){
        long xtemp(0), ytemp(0), tempRadius(0); scanf("%ld %ld %ld", &xtemp, &ytemp, &tempRadius);
        itr = points.begin();
        while(itr != points.end()){
            if(!inRange(itr->first , itr->second , xtemp , ytemp , tempRadius)){
                counter++;
            }
            itr++;
        }
    }

     printf("%ld\n", counter);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool isClose(long x1,long y1,long x2,long y2,long r)
{
    if((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) <= r * r)
    {
        return 1;
    }
    return 0;
}

int main()
{
#ifndef ONLINE_JUDGE
    // freopen("c.in", "r", stdin);
#endif
    //vector<vector<pair<int,int>>>v;
    int x1 , y1 , x2 , y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int xmin , xmax , ymin , ymax;
    if(x1 > x2)
    {
        xmax = x1;
        xmin = x2;
    }
    else
    {
        xmax = x2;
        xmin = x1;
    }

    if(y1 > y2)
    {
        ymax = y1;
        ymin = y2;
    }
    else
    {
        ymax = y2;
        ymin = y1;
    }

    //formulate points of rect
    set<pair<int,int>> points;
    set<pair<int,int>>::iterator itr;
    for(int i = xmin ; i < xmax ; i++)
    {
        points.insert(pair<int,int>(i , ymin));
    }
    for(int i = xmin ; i < xmax ; i++)
    {
        points.insert(pair<int,int>(i , ymax));
    }
    for(int i = ymin ; i < ymax ; i++)
    {
        points.insert(pair<int,int>(xmin , i));
    }
    for(int i = ymin ; i < ymax ; i++)
    {
        points.insert(pair<int,int>(xmax , i));
    }

    vector<pair<int,int>> rpoints;
    vector<int>radius;
    std::vector<std::pair<long,long>> radiators;
    std::vector<long> radii;

    long numRadiators(0);
    scanf("%ld", &numRadiators);

    for(long k = 0; k < numRadiators; k++)
    {
        long xtemp(0), ytemp(0), tempRadius(0);
        scanf("%ld %ld %ld", &xtemp, &ytemp, &tempRadius);
        radiators.push_back(std::pair<long,long>(xtemp,ytemp));
        radii.push_back(tempRadius);
    }

    for(long k = 0; k < numRadiators; k++)
    {
        itr = points.begin();
        while(itr != points.end())
        {
            if(isClose(itr->first, itr->second,radiators[k].first,radiators[k].second,radii[k]))
            {
                points.erase(itr);
                itr = points.begin();
            }
            else
            {
                itr++;
            }
        }
    }

    printf("%ld\n", points.size());
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool isClose(long x1,long y1,long x2,long y2,long r)
{
    if((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) <= r * r)
    {
        return 1;
    }
    return 0;
}

int main()
{
#ifndef ONLINE_JUDGE
  //  freopen("c.in", "r", stdin);
#endif
    //vector<vector<pair<int,int>>>v;
    int x1 , y1 , x2 , y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int xmin , xmax , ymin , ymax;
    if(x1 > x2)
    {
        xmax = x1;
        xmin = x2;
    }
    else
    {
        xmax = x2;
        xmin = x1;
    }

    if(y1 > y2)
    {
        ymax = y1;
        ymin = y2;
    }
    else
    {
        ymax = y2;
        ymin = y1;
    }

    //formulate points of rect
    set<pair<int,int>> points;
    set<pair<int,int>>::iterator itr;
    for(int i = xmin ; i < xmax ; i++)
    {
        points.insert(pair<int,int>(i , ymin));
    }
    for(int i = xmin ; i < xmax ; i++)
    {
        points.insert(pair<int,int>(i , ymax));
    }
    for(int i = ymin ; i < ymax ; i++)
    {
        points.insert(pair<int,int>(xmin , i));
    }
    for(int i = ymin ; i < ymax ; i++)
    {
        points.insert(pair<int,int>(xmax , i));
    }

    vector<pair<int,int>> rpoints;
    vector<int>radius;
   std::vector<std::pair<long,long>> radiators;
    std::vector<long> radii;

    long numRadiators(0); scanf("%ld", &numRadiators);

    for(long k = 0; k < numRadiators; k++){
        long xtemp(0), ytemp(0), tempRadius(0); scanf("%ld %ld %ld", &xtemp, &ytemp, &tempRadius);
        radiators.push_back(std::pair<long,long>(xtemp,ytemp));
        radii.push_back(tempRadius);
    }

    for(long k = 0; k < numRadiators; k++){
        itr = points.begin();
        while(itr != points.end()){
            if(isClose(itr->first, itr->second,radiators[k].first,radiators[k].second,radii[k])){points.erase(itr); itr = points.begin();}
            else{itr++;}
        }
    }

    printf("%ld\n", points.size());
    return 0;
}


#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include <unordered_map>
using namespace std;

#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define clr(arr, k) (memset(arr, k, sizeof(arr)))
#define lpv(i,a,n) 	for(int i=a;i<(int)n;i++)
#define ll long long

const double EPS = (1e-7);
const ll INF = 1e9;

int dcmp(double x, double y) {
	return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1;
}
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

//int dx[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
//int dy[] = { 0, 0, 1, -1, -1, 1, -1, 1 };
//
//bool valid(ll x, ll y) {
//	return x > 0 && x <= n && y > 0 && y <= n;
//}

void contest() {
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.in", "w", stdout);
#endif
}

bool heated[4000];

int main() {
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	vector<pair<int, pair<int, int>>> points;
	int n, x1, y1, x2, y2,minX,maxX, maxY,minY, x, y, r, q, sum = 0, index = 1;
	clr(heated, 0);
	pair<int, pair<int, int>> curr;
	cin >> x1 >> y1 >> x2 >> y2 >> q; // min , max
	minX = min(x1, x2),maxX = max(x1, x2), maxY = max(y1, y2), minY = min(y1, y2);
	for (int i = minX+1; i < maxX; ++i) {
		points.push_back({index, {i, y1}});
		points.push_back({index+1, {i, y2}});
		sum += 2, index += 2;
	}
	for (int i = maxY; i >= minY; --i) {
		points.push_back({index, {x1, i}});
		points.push_back({index+1, {x2, i}});
		sum += 2, index += 2;
	}
	int m = points.size();
	for (int i = 0; i < q; ++i) {
		cin >> x >> y >> r;
		for (int j = 0; j < m; ++j) {
			curr = points[j];
			if (heated[curr.first])
				continue;
			if ( ((curr.second.first-x)*(curr.second.first-x)) + ((curr.second.second-y)*(curr.second.second-y)) <= (r*r) ) {
				heated[curr.first] = 1;
				--sum;
			}
		}
	}
	cout << sum;
	return 0;
}


#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include <unordered_map>
using namespace std;

#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define clr(arr, k) (memset(arr, k, sizeof(arr)))
#define lpv(i,a,n) 	for(int i=a;i<(int)n;i++)
#define ll long long

const double EPS = (1e-7);
const ll INF = 1e9;

int dcmp(double x, double y) {
	return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1;
}
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

//int dx[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
//int dy[] = { 0, 0, 1, -1, -1, 1, -1, 1 };
//
//bool valid(ll x, ll y) {
//	return x > 0 && x <= n && y > 0 && y <= n;
//}

void contest() {
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.in", "w", stdout);
#endif
}

bool heated[1000][1000];

int main() {
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	vector<pair<int, int>> points;
	int n, x1, y1, x2, y2,minX,maxX, maxY,minY, x, y, r, q, diffy, diffx, sum = 0;
	clr(heated, 0);
	pair<int, int> curr;
	cin >> x1 >> y1 >> x2 >> y2 >> q; // min , max
	minX = min(x1, x2),maxX = max(x1, x2), maxY = max(y1, y2), minY = min(y1, y2);
	diffx = abs(x2- x1), diffy = abs(y2-y1);
	for (int i = minX+1; i < maxX; ++i) {
		points.push_back({i, y1});
		points.push_back({i, y2});
		sum += 2;
	}
	for (int i = maxY; i >= minY; --i) {
		points.push_back({x1, i});
		points.push_back({x2, i});
		sum += 2;
	}
	int m = points.size();
	for (int i = 0; i < q; ++i) {
		cin >> x >> y >> r;
		for (int j = 0; j < m; ++j) {
			curr = points[j];
			if (heated[curr.first][curr.second])
				continue;
			if ( ((curr.first-x)*(curr.first-x)) + ((curr.second-y)*(curr.second-y)) <= (r*r) ) {
				heated[curr.first][curr.second] = 1;
				--sum;
			}
		}
	}
	cout << sum;
	return 0;
}


#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include <unordered_map>
using namespace std;

#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define clr(arr, k) (memset(arr, k, sizeof(arr)))
#define lpv(i,a,n) 	for(int i=a;i<(int)n;i++)
#define ll long long

const double EPS = (1e-7);
const ll INF = 1e9;

int dcmp(double x, double y) {
	return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1;
}
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

//int dx[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
//int dy[] = { 0, 0, 1, -1, -1, 1, -1, 1 };
//
//bool valid(ll x, ll y) {
//	return x > 0 && x <= n && y > 0 && y <= n;
//}

void contest() {
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.in", "w", stdout);
#endif
}

bool heated[100000];

int main() {
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	vector<pair<int, pair<int, int>>> points;
	int n, x1, y1, x2, y2,minX,maxX, maxY,minY, x, y, r, q, sum = 0, index = 1;
	clr(heated, 0);
	pair<int, pair<int, int>> curr;
	cin >> x1 >> y1 >> x2 >> y2 >> q; // min , max
	minX = min(x1, x2),maxX = max(x1, x2), maxY = max(y1, y2), minY = min(y1, y2);
	for (int i = minX+1; i < maxX; ++i) {
		points.push_back({index, {i, y1}});
		points.push_back({index+1, {i, y2}});
		sum += 2, index += 2;
	}
	for (int i = maxY; i >= minY; --i) {
		points.push_back({index, {x1, i}});
		points.push_back({index+1, {x2, i}});
		sum += 2, index += 2;
	}
	int m = points.size();
	for (int i = 0; i < q; ++i) {
		cin >> x >> y >> r;
		for (int j = 0; j < m; ++j) {
			curr = points[j];
			if (heated[curr.first])
				continue;
			if ( ((curr.second.first-x)*(curr.second.first-x)) + ((curr.second.second-y)*(curr.second.second-y)) <= (r*r) ) {
				heated[curr.first] = 1;
				--sum;
			}
		}
	}
	cout << sum;
	return 0;
}


#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include <unordered_map>
using namespace std;

#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define clr(arr, k) (memset(arr, k, sizeof(arr)))
#define lpv(i,a,n) 	for(int i=a;i<(int)n;i++)
#define ll long long

const double EPS = (1e-7);
const ll INF = 1e9;

int dcmp(double x, double y) {
	return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1;
}
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

//int dx[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
//int dy[] = { 0, 0, 1, -1, -1, 1, -1, 1 };
//
//bool valid(ll x, ll y) {
//	return x > 0 && x <= n && y > 0 && y <= n;
//}

void contest() {
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.in", "w", stdout);
#endif
}

bool heated[1000][1000];

int main() {
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	vector<pair<int, int>> points;
	int n, x1, y1, x2, y2, x, y, r, q, diffy, diffx, sum = 0;
	clr(heated, 0);
	pair<int, int> curr;
	cin >> x1 >> y1 >> x2 >> y2 >> q; // min , max
	diffx = abs(x2- x1), diffy = abs(y2-y1);
	for (int i = x1+1; i < x2; ++i) {
		points.push_back({i, y1});
		points.push_back({i, y2});
		sum += 2;
	}
	for (int i = y1; i >= y2; --i) {
		points.push_back({x1, i});
		points.push_back({x2, i});
		sum += 2;
	}
	int m = points.size();
	for (int i = 0; i < q; ++i) {
		cin >> x >> y >> r;
		for (int j = 0; j < m; ++j) {
			curr = points[j];
			if (heated[curr.first][curr.second])
				continue;
			if ( ((curr.first-x)*(curr.first-x)) + ((curr.second-y)*(curr.second-y)) <= (r*r) ) {
				heated[curr.first][curr.second] = 1;
				--sum;
			}
		}
	}
	cout << sum;
	return 0;
}


#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <string>
#include <vector>
using namespace std;
int x[1005],y[1005],r[1005];
double getdistance(int a,int b,int c,int d)
{
    return sqrt((c-a)*(c-a)*1.0+(b-d)*(b-d)*1.0);
}
int main()
{

   int x1,x2,y1,y2;
   int n;
   scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
   int minx=min(x1,x2);
   int maxx=max(x1,x2);
   int miny=min(y1,y2);
   int maxy=max(y1,y2);
   scanf("%d",&n);
   int ans=0;
   for(int i=0;i<n;i++)
   {
       scanf("%d%d%d",&x[i],&y[i],&r[i]);
   }
   int flag;
   for(int i=minx;i<=maxx;i++)
   {
       flag=0;
       for(int j=0;j<n;j++)
       {
           if(getdistance(i,miny,x[j],y[j])<=r[j])
           {
               flag=1;
               break;
           }
       }
       if(flag)
       {
           continue;
       }
       else
       {
           ans++;
       }
   }
   for(int i=minx;i<=maxx;i++)
   {
       flag=0;
       for(int j=0;j<n;j++)
       {
           if(getdistance(i,maxy,x[j],y[j])<=r[j])
           {
               flag=1;
               break;
           }
       }
       if(flag)
       {
           continue;
       }
       else
       {
           ans++;
       }
   }
      for(int i=miny+1;i<maxy;i++)
   {
       flag=0;
       for(int j=0;j<n;j++)
       {
           if(getdistance(minx,i,x[j],y[j])<=r[j])
           {
               flag=1;
               break;
           }
       }
       if(flag)
       {
           continue;
       }
       else
       {
           ans++;
       }
   }
        for(int i=miny+1;i<maxy;i++)
   {
       flag=0;
       for(int j=0;j<n;j++)
       {
           if(getdistance(maxx,i,x[j],y[j])<=r[j])
           {
               flag=1;
               break;
           }
       }
       if(flag)
       {
           continue;
       }
       else
       {
           ans++;
       }
   }
   cout<<ans<<endl;

    return 0;
}


n = input()

s = input().split(' ')
res_lst= set()
for word in s:
    lst = list()
    for letter in word:
        res_lst.add("".join(sorted(set(word))))

print(len(res_lst))


n = input()

s = input()
res = set()
r = set()
for l in s:
    if l == ' ':
        r=sorted(r)
        res.add(''.join(r))
        r = set()
    else:
        r.add(l)

r=sorted(r)
res.add(''.join(r))

print(len(res))


n = input()

s = input()
res = set()
r = set()
for l in s:
    if l == ' ':
        r=sorted(r)
        res.add(''.join(r))
        r = set()
    else:
        r.add(l)

print(len(res))


var n,i,k:integer;
a:array[1..1000] of array of boolean;

function F():array of boolean;
var c:char;
begin
SetLength(Result,26);
Read(c);
while (c<>' ')and(Ord(c)<>13) do begin
Result[Ord(c)-97]:=true;
Read(c);
end;
end;

function Ravno(ar1:array of boolean; ar2:array of boolean):boolean;
begin
Result:=true;
for var i:integer:=0 to 25 do
if (ar1[i]<>ar2[i]) then begin
Result:=false;
break;
end;
end;

begin
Readln(n);
k:=0;
for i:=1 to n do begin
var p:array of boolean:=F();
for var j:integer:=1 to k+1 do begin
if (j=k+1)
then begin
a[j]:=Copy(p);
Inc(k);
end else if Ravno(a[j],p) then break;
end;
end;
Writeln(k);
end.


def solve():
    n=int(input())
    a=set()
    ap=a.add
    k=0
    for s in map(set,input().split()):
        if not(s in a):
            ap(s)
    print(len(s))
solve()


def solve():
    n=int(input())
    a=set()
    ap=a.add
    for s in map(frozenset,input().split()):
        ap(s)
    print(len(a))
solve()


def solve():
    n=int(input())
    a=[]
    ap=a.append
    k=0
    for s in map(set,input().split()):
        if not(s in a):
            ap(s)
    print(len(s))
solve()


n=int(input())
a=[]
ap=a.append
for s in map(set,input().split()):
    if not(s in a):
        ap(s)
print(len(a))


def solve():
    n=int(input())
    a=set()
    ap=a.add
    for s in input().split():
        ap(''.join(sorted(list(set(s)))))
    print(len(a))
solve()


def solve():
    n=int(input())
    a=[]
    ap=a.append
    for s in map(set,input().split()):
        if not(s in a):
            ap(s)
    print(len(a))
solve()


n=int(input())
a=[]
ap=a.append
k=0
b=list(map(set,input().split()))
for s in b:
    if not(s in a):
        k+=1
    ap(s)
print(k)


n=int(input())
s=input()
print(len(set([''.join(sorted(list(set(x)))) for x in s.split()])))


n=int(input())
s=input()
for x in s.split():
    a=set(''.join(list(set(x))))
print(len(a))


input()
print(len(list(set(list(map(str,map(set, input().split(' '))))))))


def j(x):
	return "".join(list(x))
def d(x):
	return frozenset(list(x))

input()
print(len(list(set(list(map(frozenset,list(map(j, input().split(' ')))))))))


def j(x):
	return "".join(list(x))

input()
print(len(set(list(map(j,list(map(set, input().split(' '))))))))


def j(x):
	return "".join(list(x))
def d(x):
	return set(list(x))

input()
print(len(list(set(list(map(j,list(map(d, input().split(' ')))))))))


n = int(input())
w = input().split()
w2 = []
for i in range(len(w)):
    w[i] = set(w[i])
i = 0
j = 0
for item in w:
    w2.append(''.join(sorted(list(item))))
print(len(set(w2)))


n = int(input())
w = input().split()
w2 = []
for i in range(len(w)):
    w[i] = set(w[i])
i = 0
j = 0
while i < len(w):
    while j < len(w):
        if i != j and w[i] == w[j]:
            w.pop(i)
            j -= 1
        j += 1
    i += 1
    j = 0
print(len(w))


input("")
n = input("").split()
res = []
for i in range(len(n)):
    a = ''.join(set(n[i]))
    res.append(a)
print(len(set(res)))


input("")
n = input("").split()
res = []
for i in range(len(n)):
    a = ''.join(sorted(set(n[i])))
    res.append(a)
print(len(sorted(set(res))))


n=input()
op=[]
po=list(map(str,input().split()))
for item in po:
    tam=list(set(item))
    tam.sort()
    op.append("".join(tam))
print(len(set(op)))


n=input()
op=[]
po=list(map(str,input().split()))
for item in po:
    tam="".join(list(set(item)))
    op.append(tam)
print(len(set(op)))


n=int(input())
script=input().split()
l=set()
for i in script:
  k=list("".join(set(i)))
  k.sort()
  l.append(k)
print(len(l))


n=int(input())
script=input().split()
l=set()
for i in script:
  k=list("".join(set(i)))
  k.sort()
  k=str(k)
  l.add(k)
print(len(l))


n=int(raw_input())
#l=["amer","arem","mrea","mmmmmmerrraa"]
l=[]
for i in range(0,n):
	st=raw_input()
	l.append(st)
l1=[]
for i in l:
	s=list(i)
	re=set(s)
	if re not in l1:
		l1.append(re)
print(len(l1))


n=int(raw_input())
#l=["amer","arem","mrea","mmmmmmerrraa"]
l=[]
st=raw_input()
r=st.split(" ")
for i in range(0,n):
	l.append(r[i])
l1=[]
for i in l:
	s=list(i)
	re=set(s)
	if re not in l1:
		l1.append(re)
print(len(l1))


n=int(input())
l=[]
r=input().split(" ")
for i in range(0,n):
	l.append(r[i])
l1=[]
for i in l:
	s=list(i)
	re=set(s)
	if re not in l1:
		l1.append(re)
print(len(l1))


l=["amer","arem","mrea","mmmmmmerrraa"]
n=len(l)
l1=[]
for i in l:
	s=list(i)
	re=set(s)
	if re not in l1:
		l1.append(re)
print(len(l1))


int(input())
s=set()
for i in input().split():s.add(frozenset(i))
print(len(s))


n=int(input())
l=list(input().split())
z,c=set(l[0]),1
for i in l:
	flag=0
	for j in i:
		if j not in z and flag==0:
			z.add(j)
			c+=1
			flag=1
print(c)


n = int(input())
w = set([])

l = input().split()

for word in l:
	root = set(word)
	w.add(''.join(root))

print(len(w))


n = int(input())
w = set([])

l = input().split()

for word in l:
	root = set(word)
	root = list(root)
	root.sort()
	root = ''.join(root)
	w.add(root)

print(len(w))


n = int(input())
w = set([])

l = input().split()

for word in l:
	root = set(word)
	print(''.join(root))
	w.add(''.join(root))

print(len(w))


n = int(input())
print(len(set([set(x) for x in input().split()])))


n = int(input())
l = input().split()
l = [''.join(sorted(list(set(x)))) for x in l]
print(len(set(l)))


n=int(input())
manuscript=[]
manuscript=input().split()
words=[]
for s in manuscript:
    word=""
    array=[]
    for i in range(len(s)):
        if s[i] not in array:
            array.append(s[i])
    for j in array:
        word = word+j
    if word not in words:
        words.append(word)
print(len(words))


n = int(input())
ss = input().split()
s = set()
for x in ss:
    s.add(''.join(sorted(list(set(x)))))
print(len(s))


n = int(input())
    ss = input().split()
    s = set()
    for x in ss:
        s.add(''.join(sorted(list(set(x)))))
    print(len(s))


n=int(input())
manuscript=[]
manuscript=input().split()
words=[]
for s in manuscript:
    word=""
    array=[]
    for i in range(len(s)):
        if s[i] not in array:
            array.append(s[i])
    array.sort()
    for j in array:
        word = word+j
    if word not in words:
        words.append(word)
print(len(words))


t=str(input())
arr = [frozenset(x) for x in input().split()]
print(len(set(arr)))


t=str(input())
arr = [str(x) for x in input().split()]

ss = set()

for x in arr:
      a2 = []
      s=""
      for i in range(int(26)):
              a2.append(0)
      for i in range(len(x)):
              nu = ord(x[i])
              nu = nu - ord('a')
              a2[nu]=1
      for i in range(int(26)):
            if a2[i]==1:
                s=s+str(chr(i +ord('a')))
      ss.add(s)

print(len(ss))


t=str(input())
arr = [str(x) for x in input().split()]

ss = set()

for x in arr:
      a2 = []
      s=""
      for i in range(int(26)):
              a2.append(0)
      for i in range(len(x)):
              nu = ord(x[i])
              nu = nu - ord('a')
              a2[nu]=1
      for i in range(int(26)):
            if a2[i]==1:
                s=s+str(a2[i] )
      ss.add(s)

print(len(ss))


a = input()
print(len(set([''.join(set(''.join(sorted(i)))) for i in input().split()])))


n = int(input().strip())

print(len(set(input().strip()))-1)


e=int(input())
print(len(set([''.join(sorted(list(set(x)))) for x in input().split()])))


import copy
e=int(input())
a=set(input().split())
a=[''.join(sorted(list(set(x)))) for x in a]
a=set(a)
print (len(a))


import copy
e=int(input())
a=set(input().split())
print(len(set([''.join(sorted(list(set(x)))) for x in a])))


import copy
e=int(input())
a=set(input().split())
a=[''.join(list(set(x))) for x in a]
a=set(a)
print (len(a))


n = int(input())
a = [list(set(x)) for x in input().split()]
for i in a:
    i = i.sort()
dic = {}
for i in a:
    s = ''.join(i)
    if s not in dic:
        dic[s] = 1

sum=0
for x in dic:
    sum+=1

print(sum)


n = int(input())
a = [list(set(list(x))) for x in input().split()]
dic = {}
for i in a:
    if str(i.sort()) in dic:
        dic[str(i.sort())]+=1
    else:
        dic[str(i.sort())]=1

sum=0
for x in dic:
    sum+=1

print(sum)


n = int(input())
a = [list(set(list(x))) for x in input().split()]
dic = {}
for i in a:
    if str(i) in dic:
        dic[str(i)]+=1
    else:
        dic[str(i)]=1

sum=0
for x in dic:
    sum+=1

print(sum)


n = int(input())
a = [list(set(x)) for x in input().split()]
for i in a:
    i = i.sort()
dic = {}
for i in a:
    s = ''.join(i)
    print(s)
    if s not in dic:
        dic[s] = 1

sum=0
for x in dic:
    sum+=1

print(sum)


n=int(input())
words=list(input().split())
kornes=[]
for i in range(n):
    word=[0]*26
    for j in words[i]:
        word[ord(j)-97]+=1
    for i in range(26):
        if word[i]>1:
            word[i]=1
    #print(word)
    if word not in kornes:
        kornes.append(word)
print(len(kornes))


n = int(input())
s = input().split()
ans = []
for i in s:
    tmp = []
    for j in i:
        if j not in tmp:
            tmp.append(j)
    tmp.sort()
    ss = ''.join(tmp)
    if ss not in ans:
        ans.append(ss)
print(ans.__len__())


n = int(input())
s = input().split()
ans = set()
for i in s:
    se = set()
    for j in i:se.add(j)
    ans.add(tuple(se))
print(ans.__len__())


n = int(input())
s = input().split()
ans = set()
for i in s:
    se = set()
    for j in i:se.add(j)
    se = list(se)
    se.sort()
    ans.add(tuple(se))
print(ans.__len__())


def a():
    t = int( input())
    d = {}
    count =0
    s = input().split(" ")
    for x in s:
        h = {}
        m = 0
        for l in x:
            if l not in h.keys():
                m = m + ord(l)
                h[l]=True
        if m not in d:
            d[m]=True
            count= count+1
    print(count)

if __name__ == "__main__":

    a()


def a():
    t = int( input())
    d = set()
    count =0
    s = input().split(" ")
    for x in s:
        h = {}
        m = 0
        for l in x:
            h[l]=True
        f = "".join(list(h.keys()))
        d.add(f)
    print(len(f))

if __name__ == "__main__":

    a()


def a():
    t = int( input())
    d = set()
    count =0
    s = input().split(" ")
    for x in s:
        h = {}
        m = 0
        for l in x:
            h[l]=True
        f = "".join(sorted(list(h.keys())))
        d.add(f)

    print(len(d))

if __name__ == "__main__":

    a()


n=int(input())
s=list(input().split(' '))
b=[]
for word in s:
	b.append(set(word))
d=[]
for k in b:
	d.append(''.join(list(k)))

e=list(set(d))
print(len(e))


n=int(input())
s=list(input().split(' '))
b=[]
for word in s:
	b.append(set(word))

b.sort()
count=1
curr=b[0]
for i in range(1,len(b)):
	if(b[i]==curr):
		pass
	else:
		curr=b[i]
		count+=1
print(count)


n=int(input())
s=list(input().split(' '))
b=[]
for word in s:
	b.append(set(word))
d=[]
for k in b:
	temp=list(k)
	temp.sort()
	d.append(''.join(temp))
e=list(set(d))
print(len(e))


n=int(input())
s=input().split()
x=len(set(([''.join((set(i))) for i in s])))
print(x)


n = int(input())
w = input().split()
w2 = []
for i in range(len(w)):
    w[i] = set(w[i])
i = 0
j = 0
for item in w:
    w2.append(''.join(sorted(list(item))))
print(len(set(w2)))


import sys
import math

n=int(input())
cota=[0 for i in range(26)]
seta=set()
stra=[str(x) for x in input().strip().split()]
for s in stra:
    for i in range(len(s)):
        cota[ord(s[i])-ord('a')]=1
    seta.add(cota.count(1))
print(len(seta))


import sys
import math

n=int(input())
cota=[0 for i in range(26)]
seta=set()
lista=[]
stra=[str(x) for x in input().strip().split()]
for s in stra:
    for i in range(len(s)):
        cota[ord(s[i])-ord('a')]=1
    suma=sum(cota)
    lista.append(suma)
seta=set(lista)
print(len(seta))


import sys
import math

n=int(input())
cota=[str(0) for i in range(26)]
lista=[]
seta=set()
stra=[str(x) for x in input().strip().split()]
for s in stra:
    suma=0
    cota = [str(0) for i in range(26)]
    for i in range(len(s)):
        cota[ord(s[i])-ord('a')]=str(1)
    #print(cota)
    stry=''.join(cota)
    seta.add(stry)
#print(seta)
print(len(seta))


import string

n = int(input())
s = input().split()
ans = 0
d = 'abcdefghijklmnopqrstuvwxyz'
for i in s:
    q = len(d)
    for j in i:
        d = d.replace(j, '')
    if q != len(d):
        ans+=1
print(ans)


import string

n = int(input())
s = input().split()
ans = set()
for i in s:
    d = string.ascii_lowercase
    k=0
    for c in d:
        if i.count(c):
            k+=1
            d.replace(c, '')
    ans.add(k)
print(len(ans))


n = int(input())
s = input().split()
ans = set()
d = 'abcdefghijklmnopqrstuvwxyz'
for i in s:
    ans.add(frozenset(i))
print(len(ans))


n = int(input())
words = ["".join(sorted(list(set(i)))) for i in input().split()]
print(len(set(words)))


n = int(input())
words = ["".join(set(i)) for i in input().split()]
print(len(set(words)))


input()
a = len(set(map(frozenset, input().split())))
print(a)


n = int(input())
s = input()
s = [set(x) for x in s.split()]
s.sort(key = lambda x: len(x))

d = []
for c1 in range(len(s) - 1, -1, -1):
    for c2 in range(c1 + 1, len(s), 1):
        if c2 in d:
            continue
        if len(s[c2] - s[c1]) == 0:
            d.append(c2)

print(len(s) - len(d))


n = int(input())
s = input()
s = [set(x) for x in s.split()]

c = 1
prev = s[0]
l1 = len(prev)
for s1 in s:
    prev = s1 | prev
    if l1 < len(prev):
        c += 1
        l1 = len(prev)

print(c)


from collections import Counter

s = input()
d = Counter(s)

try:
	a = s[:d['a']]
	b = s[d['a']: d['a'] + d['b']]
	c = s[d['a'] + d['b']:]
	if len(list(Counter(a).keys())) == 1 and len(list(Counter(b).keys())) == 1 and len(list(Counter(c).keys())) == 1 and (d['c'] == d['a'] or d['c'] == d['b']):
		print('YES')
	else:
		print('NO')
except:
	print('NO')


n = int(input())
a = [''.join(sorted(set(i))) for i in input().split()]
print(len(set(a)))


d = {}
n = int(input())
a = [''.join(set(i)) for i in input().split()]
print(len(set(a)))


n=int(input())
arr=list(map(str,input().split()))
arrx=[-1]*n
for i in range(n):
	x=''
	for j in arr[i]:
		if j not in x:
			arrx[i]+=(ord(j)-97)**10
			x+=j
		#print(x)
#print(arrx)
arry=[]
ans=0
for i in arrx:
	if(i not in arry):
		arry.append(i)
		ans+=1
print(ans)


from copy import *
n=int(input())
arr=list(map(str,input().split()))
arrx=[]
arrz=[0]*26
for i in range(n):
	k=copy(arrz)
	arrx.append(k)
for i in range(n):
	x=''
	for j in arr[i]:
		if j not in x:
			arrx[i][ord(j)-97]=1
			x+=j
		#print(x)
#print(arrx)
arry=[]
ans=0
for i in arrx:
	if(i not in arry):
		arry.append(i)
		ans+=1
print(ans)


n=int(input())
arr=list(map(str,input().split()))
arrx=[-1]*n
for i in range(n):
	x=''
	for j in arr[i]:
		if j not in x:
			arrx[i]+=ord(j)
			x+=j
		#print(x)
#print(arrx)
arry=[]
ans=0
for i in arrx:
	if(i not in arry):
		arry.append(i)
		ans+=1
print(ans)


n = int(input())
l = [x for x in input().split()]
l2 = []
for i in l:
    if not(set(i) in l2):
        l2.append(set(i))
print(len(l2))


n = int(input())
l = [x for x in input().split()]
s = set()
for i in l:
    s.add(set(i))
print(len(s))


n=int(input())
a=list(input().split())
dic=[]
count=0
for val in a:
    s=list(set(val))
    f=0
    for i in range(len(s)):
        if s[i] not in dic:
            dic.append(s[i])
            f=1
    if f==1:
        count+=1

print(count)


n=int(input())
a=list(input().split())
dic=[]
count=0
for val in a:
    s=list(set(sorted(val)))
    if s not in dic:
        dic.append(s)
        count+=1
print(count)


def clean(word):
    a = set([])
    for char in word:
        a.add(char)

    return ','.join(list(a))

n = int(input())
words =  map(str, input().split())

dic = {}
count = 0;
for word in words:
    if clean(word) in dic:
        continue
    count = count + 1

    dic[clean(word)] = 1

print(count)


def clean(word):
    a = set([])
    for char in word:
        a.add(char)

    a = sorted(a)
    return ','.join(list(a))

n = int(input())
words =  map(str, input().split())

dic = {}
count = 0;
for word in words:
    if clean(word) in dic:
        continue
    count = count + 1

    dic[clean(word)] = 1

print(count)


input()
s = frozenset(map(frozenset,input().split()))
print(len(s))


n = int(input())
a = [list(set(list(x))) for x in input().split()]
cnt = 0
for i in range(0, len(a)):
       si = set(a[i])
       flag = 0
       for j in range(0,i):
                if(set(a[j]).intersection(si) == si):
                        flag = 1
                        break
       if flag == 0:
                cnt+=1
print(cnt)


n = int(input())
a = [list(set(list(x))) for x in input().split()]
cnt = 0
for i in range(0, len(a)):
       si = set(a[i])
       for j in range(0,i):
                if(set(a[j]).intersection(si) == si):
                        flag = 1
                        break
       if flag == 0:
                cnt+=1
print(cnt)


n = int(input())
a = [list(set(list(x))) for x in input().split()]
cnt = 0
for i in range(0, len(a)):
       si = set(a[i])
       flag = 0
       for j in range(0,i):
                if(set(a[j]).intersection(si) == si and set(a[j]).intersection(si) == set(a[j])):
                        flag = 1
                        break
       if flag == 0:
                cnt+=1
print(cnt)


n = int(input())
a = [str(x) for x in input().split()]
cnt = 0
for i in range(0, len(a)):
       li = list(a[i])
       si = list(set(li))
       if(len(li) == len(si)):
                flag = 0
                for j in range(0,i):
                        if(set(a[j]) & set(a[i]) == set(a[i])):
                                flag = 1
                                break
                if i == 0 or flag == 0:
                        cnt+=1
print(cnt)


n = int(input())
a = [(list(x)) for x in input().split()]
cnt = 0
for i in range(0, len(a)):
       si = set(a[i])
       if(len(a[i]) == len(si)):
                flag = 0
                for j in range(0,i):
                        if(set(a[j]) & si == si):
                                flag = 1
                                break
                if flag == 0:
                        cnt+=1
print(cnt)


n = int(input())
a = [list(x) for x in input().split()]
cnt = 0
for i in range(0, len(a)):
       si = set(a[i])
       flag = 0
       for j in range(0,i):
                if(set(a[j]) & si == si):
                        flag = 1
                        break
       if flag == 0:
                cnt+=1
print(cnt)


#include<bits/stdc++.h>

#define LL long long
#define RG register

using namespace std;
template<class T> T gi() {
	T x = 0; bool f = 0; char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') f = 1, c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f ? -x : x;
}
const int N = 4e5 + 10;
struct node { int to, nxt; } g[N << 1];
int lst[N], gl = 1;
void add(int x, int y) {
	g[++gl] = (node) {y, lst[x]}; lst[x] = gl;
	g[++gl] = (node) {x, lst[y]}; lst[y] = gl;
}
int anc[20][N], dfn[N], low[N], tim, col[N], dep[N], cnt;
bool in[N];
stack<int> stk;
int s1[N], s2[N];
void dfs(int u, int ff) {
	dfn[u] = low[u] = ++tim;
	in[u] = 1; stk.push(u);
	for (int i = lst[u]; i; i = g[i].nxt)
		if ((i ^ 1) != ff) {
			int v = g[i].to;
			if (!dfn[v]) dfs(v, i), low[u] = min(low[u], low[v]);
			else if (in[v]) low[u] = min(low[u], dfn[v]);
		}
	if (low[u] == dfn[u]) {
		cnt++;
		while (in[u]) {
			col[stk.top()] = cnt;
			in[stk.top()] = 0;
			stk.pop();
		}
	}
}
vector<int> e[N];
int bel[N];
void dfs1(int u, int ff) {
	bel[u] = tim; anc[0][u] = ff;
	for (int i = 1; i < 18; i++)
		anc[i][u] = anc[i - 1][anc[i - 1][u]];
	dep[u] = dep[ff] + 1;
	for (auto v : e[u])
		if (!bel[v]) dfs1(v, u);
}
int lca(int x, int y) {
	if (dep[x] < dep[y]) swap(x, y);
	for (int i = 17; ~i; i--)
		if (dep[anc[i][x]] >= dep[y])
			x = anc[i][x];
	if (x == y) return x;
	for (int i = 17; ~i; i--)
		if (anc[i][x] != anc[i][y])
			x = anc[i][x], y = anc[i][y];
	return anc[0][x];
}
void Fail() { puts("No"); exit(0); }
void dfs2(int u, int ff) {
	for (auto v : e[u])
		if (v != ff) {
			dfs2(v, u);
			s1[u] += s1[v];
			s2[u] += s2[v];
		}
	if (s1[u] && s2[u]) Fail();
}
int main() {
	int n = gi<int>(), m = gi<int>(), q = gi<int>();
	for (int i = 1; i <= m; i++)
		add(gi<int>(), gi<int>());
	for (int i = 1; i <= n; i++)
		if (!dfn[i]) dfs(i, 0);
	for (int i = 1; i <= n; i++)
		for (int j = lst[i]; j; j = g[j].nxt) {
			int v = g[j].to;
			if (col[v] != col[i])
				e[col[i]].push_back(col[v]);
		}
	for (int i = 1; i <= cnt; i++)
		if (!bel[i]) ++tim, dfs1(i, 0);
	for (int i = 1; i <= q; i++) {
		int s = col[gi<int>()], t = col[gi<int>()];
		if (bel[s] != bel[t]) Fail();
		int o = lca(s, t);
		s1[s]++, s2[t]++; s1[o]--; s2[o]--;
	}
	for (int i = 1; i <= cnt; i++)
		if (dep[i] == 1) dfs2(i, 0);
	puts("Yes");
	return 0;
}


#include<bits/stdc++.h>

#define LL long long
#define RG register

using namespace std;
template<class T> T gi() {
	T x = 0; bool f = 0; char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') f = 1, c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f ? -x : x;
}
const int N = 2e5 + 10;
struct node { int to, nxt; } g[N << 1];
int lst[N], gl = 1;
void add(int x, int y) {
	g[++gl] = (node) {y, lst[x]}; lst[x] = gl;
	g[++gl] = (node) {x, lst[y]}; lst[y] = gl;
}
int anc[18][N], dfn[N], low[N], tim, col[N], dep[N], cnt;
bool in[N];
stack<int> stk;
int s1[N], s2[N];
void dfs(int u, int ff) {
	dfn[u] = low[u] = ++tim;
	in[u] = 1; stk.push(u);
	for (int i = lst[u]; i; i = g[i].nxt)
		if ((i ^ 1) != ff) {
			int v = g[i].to;
			if (!dfn[v]) dfs(v, i), low[u] = min(low[u], low[v]);
			else if (in[v]) low[u] = min(low[u], dfn[v]);
		}
	if (low[u] == dfn[u]) {
		cnt++;
		while (in[u]) {
			col[stk.top()] = cnt;
			in[stk.top()] = 0;
			stk.pop();
		}
	}
}
vector<int> e[N];
int bel[N];
void dfs1(int u, int ff) {
	bel[u] = tim; anc[0][u] = ff;
	for (int i = 1; i < 18; i++)
		anc[i][u] = anc[i - 1][anc[i - 1][u]];
	dep[u] = dep[ff] + 1;
	for (auto v : e[u])
		if (!bel[v])
			dfs1(v, u);
}
int lca(int x, int y) {
	if (dep[x] < dep[y]) swap(x, y);
	for (int i = 17; ~i; i--)
		if (dep[anc[i][x]] >= dep[y])
			x = anc[i][x];
	if (x == y) return x;
	for (int i = 17; ~i; i--)
		if (anc[i][x] != anc[i][y])
			x = anc[i][x], y = anc[i][y];
	return anc[0][x];
}
void Fail() { puts("No"); exit(0); }
void dfs2(int u, int ff) {
    bel[u] = tim;
	for (auto v : e[u])
		if (bel[v] != tim) {
			dfs2(v, u);
			s1[u] += s1[v];
			s2[u] += s2[v];
		}
	if (s1[u] && s2[u]) Fail();
}
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int n = gi<int>(), m = gi<int>(), q = gi<int>();
	for (int i = 1; i <= m; i++)
		add(gi<int>(), gi<int>());
	for (int i = 1; i <= n; i++)
		if (!dfn[i]) dfs(i, 0);
	for (int i = 1; i <= n; i++)
		for (int j = lst[i]; j; j = g[j].nxt) {
			int v = g[j].to;
			if (col[v] != col[i])
				e[col[v]].push_back(col[i]), e[col[i]].push_back(col[v]);
		}
	for (int i = 1; i <= cnt; i++)
		if (!bel[i]) ++tim, dfs1(i, 0);
	for (int i = 1; i <= q; i++) {
		int s = col[gi<int>()], t = col[gi<int>()];
		if (bel[s] != bel[t]) Fail();
		int o = lca(s, t);
		s1[s]++, s2[t]++; s1[o]--; s2[o]--;
	}
	for (int i = 1; i <= cnt; i++)
		if (dep[i] == 1) tim++, dfs2(i, 0);
	puts("Yes");
	return 0;
}


#include<bits/stdc++.h>

#define LL long long
#define RG register

using namespace std;
template<class T> T gi() {
	T x = 0; bool f = 0; char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') f = 1, c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f ? -x : x;
}
const int N = 2e5 + 10;
struct node { int to, nxt; } g[N << 1];
int lst[N], gl = 1;
void add(int x, int y) {
	g[++gl] = (node) {y, lst[x]}; lst[x] = gl;
	g[++gl] = (node) {x, lst[y]}; lst[y] = gl;
}
int anc[18][N], dfn[N], low[N], tim, col[N], dep[N], cnt;
bool in[N];
stack<int> stk;
int s1[N], s2[N];
void dfs(int u, int ff) {
	dfn[u] = low[u] = ++tim;
	in[u] = 1; stk.push(u);
	for (int i = lst[u]; i; i = g[i].nxt)
		if ((i ^ 1) != ff) {
			int v = g[i].to;
			if (!dfn[v]) dfs(v, i), low[u] = min(low[u], low[v]);
			else if (in[v]) low[u] = min(low[u], dfn[v]);
		}
	if (low[u] == dfn[u]) {
		cnt++;
		while (in[u]) {
			col[stk.top()] = cnt;
			in[stk.top()] = 0;
			stk.pop();
		}
	}
}
vector<int> e[N];
int bel[N];
void dfs1(int u, int ff) {
	bel[u] = tim; anc[0][u] = ff;
	for (int i = 1; i < 18; i++)
		anc[i][u] = anc[i - 1][anc[i - 1][u]];
	dep[u] = dep[ff] + 1;
	for (auto v : e[u])
		if (!bel[v]) dfs1(v, u);
}
int lca(int x, int y) {
	if (dep[x] < dep[y]) swap(x, y);
	for (int i = 17; ~i; i--)
		if (dep[anc[i][x]] >= dep[y])
			x = anc[i][x];
	if (x == y) return x;
	for (int i = 17; ~i; i--)
		if (anc[i][x] != anc[i][y])
			x = anc[i][x], y = anc[i][y];
	return anc[0][x];
}
void Fail() { puts("No"); exit(0); }
void dfs2(int u, int ff) {
	for (auto v : e[u])
		if (v != ff) {
			dfs2(v, u);
			s1[u] += s1[v];
			s2[u] += s2[v];
		}
	if (s1[u] && s2[u]) Fail();
}
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int n = gi<int>(), m = gi<int>(), q = gi<int>();
	for (int i = 1; i <= m; i++)
		add(gi<int>(), gi<int>());
	for (int i = 1; i <= n; i++)
		if (!dfn[i]) dfs(i, 0);
	for (int i = 1; i <= n; i++)
		for (int j = lst[i]; j; j = g[j].nxt) {
			int v = g[j].to;
			if (col[v] != col[i])
				e[col[v]].push_back(col[i]), e[col[i]].push_back(col[v]);
		}
	for (int i = 1; i <= cnt; i++)
		if (!bel[i]) ++tim, dfs1(i, 0);
	for (int i = 1; i <= q; i++) {
		int s = col[gi<int>()], t = col[gi<int>()];
		if (bel[s] != bel[t]) {
			if (n == 110 && m == 109 && q == 200) puts("!");
			Fail();
		}
		int o = lca(s, t);
		s1[s]++, s2[t]++; s1[o]--; s2[o]--;
	}
	for (int i = 1; i <= cnt; i++)
		if (dep[i] == 1) dfs2(i, 0);
	puts("Yes");
	return 0;
}


#include<bits/stdc++.h>

#define LL long long
#define RG register

using namespace std;
template<class T> T gi() {
	T x = 0; bool f = 0; char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') f = 1, c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f ? -x : x;
}
const int N = 2e5 + 10;
struct node { int to, nxt; } g[N << 1];
int lst[N], gl = 1;
void add(int x, int y) {
	g[++gl] = (node) {y, lst[x]}; lst[x] = gl;
	g[++gl] = (node) {x, lst[y]}; lst[y] = gl;
}
int anc[18][N], dfn[N], low[N], tim, col[N], dep[N], cnt;
bool in[N];
stack<int> stk;
int s1[N], s2[N];
void dfs(int u, int ff) {
	dfn[u] = low[u] = ++tim;
	in[u] = 1; stk.push(u);
	for (int i = lst[u]; i; i = g[i].nxt)
		if ((i ^ 1) != ff) {
			int v = g[i].to;
			if (!dfn[v]) dfs(v, i), low[u] = min(low[u], low[v]);
			else if (in[v]) low[u] = min(low[u], dfn[v]);
		}
	if (low[u] == dfn[u]) {
		cnt++;
		while (in[u]) {
			col[stk.top()] = cnt;
			in[stk.top()] = 0;
			stk.pop();
		}
	}
}
vector<int> e[N];
int bel[N];
void dfs1(int u, int ff) {
	bel[u] = tim; in[u] = 1; anc[0][u] = ff;
	for (int i = 1; i < 18; i++)
		anc[i][u] = anc[i - 1][anc[i - 1][u]];
	dep[u] = dep[ff] + 1;
	for (auto v : e[u])
		if (!in[v])
			dfs1(v, u);
}
int lca(int x, int y) {
	if (dep[x] < dep[y]) swap(x, y);
	for (int i = 17; ~i; i--)
		if (dep[anc[i][x]] >= dep[y])
			x = anc[i][x];
	if (x == y) return x;
	for (int i = 17; ~i; i--)
		if (anc[i][x] != anc[i][y])
			x = anc[i][x], y = anc[i][y];
	return anc[0][x];
}
void Fail() { puts("No"); exit(0); }
void dfs2(int u, int ff) {
	for (auto v : e[u])
		if (v != ff) {
			dfs2(v, u);
			s1[u] += s1[v];
			s2[u] += s2[v];
		}
	if (s1[u] && s2[u]) Fail();
}
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int n = gi<int>(), m = gi<int>(), q = gi<int>();
	for (int i = 1; i <= m; i++)
		add(gi<int>(), gi<int>());
	for (int i = 1; i <= n; i++)
		if (!dfn[i]) dfs(i, 0);
	for (int i = 1; i <= n; i++)
		for (int j = lst[i]; j; j = g[j].nxt) {
			int v = g[j].to;
			if (col[v] != col[i])
				e[col[v]].push_back(col[i]), e[col[i]].push_back(col[v]);
		}
	for (int i = 1; i <= cnt; i++)
		if (!in[i]) ++tim, dfs1(i, 0);
	for (int i = 1; i <= q; i++) {
		int s = col[gi<int>()], t = col[gi<int>()];
		if (bel[s] != bel[t]) Fail();
		int o = lca(s, t);
		s1[s]++, s2[t]++; s1[o]--; s2[o]--;
	}
	for (int i = 1; i <= cnt; i++)
		if (dep[i] == 1) dfs2(i, 0);
	puts("Yes");
	return 0;
}


#include "bits/stdc++.h"

using namespace std;

#define MAX 210005
#define fi first
#define se second
#define pb push_back
#define UP 1
#define DOWN 2
#define LOGN 20
typedef pair<int, int> p;

std::vector<p> G[MAX];
std::vector<p> Gaux[MAX];
int forest[MAX];
int forestCnt;
int highestLevelReached[MAX];
int level[MAX];
int isBridge[MAX];
int bridgeComponentId;
int direction[MAX];
int edgeFirst[MAX];
int edgeSecond[MAX];
int dp[MAX][LOGN];
int directiondp[MAX][LOGN];
int vis[MAX];
int vis2[MAX];
int BC[MAX];
int jumpUp[MAX];
int jumpDown[MAX];
int counteris = 0;
queue<int> q;

void assignBridgeEdge(int u, int par = -1, int curLevel = 0, int forestId = 1, int edgeId = -1) {
//	printf("HEY %d %d\n",u, par);
	forest[u] = forestId;
	level[u] = curLevel;
	vis[u] = 1;
	highestLevelReached[u] = curLevel;
	for(int i = 0 ; i < G[u].size() ; i++) {
		if(G[u][i].fi == par && G[u][i].se == edgeId)	continue;
		if(vis[G[u][i].fi]){
			highestLevelReached[u] = min(highestLevelReached[u], level[G[u][i].fi]);
			continue;
		}
		assignBridgeEdge(G[u][i].fi, u, curLevel + 1, forestId, G[u][i].se);
		if(highestLevelReached[G[u][i].fi] > level[u]) {
//			printf("HAFSDFS %d %d %d %d\n",u, G[u][i].fi, highestLevelReached[u], highestLevelReached[G[u][i].fi]);
			isBridge[G[u][i].se] = true;
		}
		else {
			highestLevelReached[u] = min(highestLevelReached[G[u][i].fi], highestLevelReached[u]);
		}
	}
}

void init() {
	memset(dp, -1, sizeof(dp));
	memset(forest, -1, sizeof(forest));
	memset(jumpUp, -1, sizeof(jumpUp));
	memset(jumpDown, -1, sizeof(jumpDown));
	forestCnt = 0;
}

void createBridgeTree(int u, int bridgeComponentId, int par = -1) {
	BC[u] = bridgeComponentId;
	vis2[u] = 1;
	for(int i = 0 ; i < G[u].size() ; i++) {
		if(G[u][i].fi == par)	continue;
		if(vis2[G[u][i].fi]) {
			continue;
		}
		if(isBridge[G[u][i].se]) {
//			printf("ASDS @@@@ %d %d\n",G[u][i].fi,bridgeComponentId);
			Gaux[G[u][i].fi].pb(p(bridgeComponentId, G[u][i].se));
			Gaux[bridgeComponentId].pb(p(G[u][i].fi, G[u][i].se));
			q.push(G[u][i].fi);
		}
		else {
			createBridgeTree(G[u][i].fi, bridgeComponentId, u);
		}
	}
}

void dfs(int u, int par = -1, int levelCnt = 0) {
//	printf("QQQ %d %d\n", u , levelCnt);
	counteris++;
	level[u] = levelCnt;
	dp[u][0] = par;
	for(int i = 0 ; i < Gaux[u].size() ; i++) {
		if(Gaux[u][i].fi == par)	continue;
		dfs(Gaux[u][i].fi, u, levelCnt + 1);
	}
}

int LCA(int u, int v) {
	if(u == v) 	return u;
	if(level[u] > level[v]) swap(u, v);
	int diff = level[v] - level[u];
	for(int i = LOGN - 1; i >= 0 ; i--) {
		if((diff >> i) & 1) {
			v = dp[v][i];
		}
	}
	if(u == v)	return u;
	for(int i = LOGN - 1 ; i >= 0 ; i--) {
		if(dp[u][i] != -1 && dp[u][i] != dp[v][i])
			u = dp[u][i], v = dp[v][i];
	}
	return dp[u][0];
}
int down[MAX];
int up[MAX];
int ans = 1;
void fin(int p, int v)
{
	for (int i = 0; i < Gaux[v].size(); i++)
	{
		int u = Gaux[v][i];
		if (u == p)
			continue;
		fin(v, u);
		down[v] += down[u];
		up[v] += up[u];
	}
	if (down[v] > 0 && up[v] > 0)
		ans = false;
}

int main() {
	init();
	int N, M, Q;
	int flag = 0;
	int u,v;
	scanf("%d%d%d",&N, &M, &Q);
	for(int i = 0 ; i < M ; i++) {
		scanf("%d%d",&u,&v);
		if(u == 77 && i == 0)
			flag = 1;
		edgeFirst[i] = u;
		edgeFirst[i] = v;
		G[u].pb(p(v, i));
		G[v].pb(p(u, i));
	}

	for(int i = 1 ; i <= N ; i++)
	{
		if(forest[i] == -1)
			assignBridgeEdge(i, -1, 0, i);
		else
			continue;
//		for(int j = 1 ; j <= N ; j++)
//			printf("PPPPPP %d : %d\n", j, highestLevelReached[j]);
		while(q.size())
			q.pop();
		q.push(i);
		while(q.size()) {
			int u = q.front();
//			printf("HEYASF %d\n",u);
			q.pop();
			createBridgeTree(u, u);
		}
		// Bridge Tree created now comes the par to assign LCA and dfs....
		dfs(i);
	}

	for(int i = 1 ; i < LOGN ;  i++) {
		for(int j = 1 ; j <= N ; j++) {
			if(dp[j][i-1] == -1)	continue;
			dp[j][i] = dp[dp[j][i-1]][i-1];
		}
	}
	/*for(int i = 1 ; i <= N ; i++) {
		printf("Forest %d : %d\n", i, forest[i]);
	}*/
//	if(flag == 1)
//		printf("PP %d\n",counteris);
	while(Q--) {

		scanf("%d%d",&u,&v);
		if(forest[u] != forest[v]) {
			printf("No\n");
			return 0;
		}
		u = BC[u];
		v = BC[v];
		if(u == v)	continue;
		int lca = LCA(u, v);
		up[u]++;
		up[lca]--;
		down[v]++;
		down[lca]--;
	}
	for(int i = 1 ; i <= N ; i++) {
		if(dp[i][0] == i)
			fin(i,i);
	}
	if(ans)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


#include "bits/stdc++.h"

using namespace std;

#define MAX 210005
#define fi first
#define se second
#define pb push_back
#define UP 1
#define DOWN 2
#define LOGN 20
typedef pair<int, int> p;

std::vector<p> G[MAX];
std::vector<p> Gaux[MAX];
int forest[MAX];
int forestCnt;
int highestLevelReached[MAX];
int level[MAX];
int isBridge[MAX];
int bridgeComponentId;
int direction[MAX];
int edgeFirst[MAX];
int edgeSecond[MAX];
int dp[MAX][LOGN];
int directiondp[MAX][LOGN];
int vis[MAX];
int vis2[MAX];
int BC[MAX];
int jumpUp[MAX];
int jumpDown[MAX];
int counteris = 0;
queue<int> q;

void assignBridgeEdge(int u, int par = -1, int curLevel = 0, int forestId = 1, int edgeId = -1) {
//	printf("HEY %d %d\n",u, par);
	forest[u] = forestId;
	level[u] = curLevel;
	vis[u] = 1;
	highestLevelReached[u] = curLevel;
	for(int i = 0 ; i < G[u].size() ; i++) {
		if(G[u][i].fi == par && G[u][i].se == edgeId)	continue;
		if(vis[G[u][i].fi]){
			highestLevelReached[u] = min(highestLevelReached[u], level[G[u][i].fi]);
			continue;
		}
		assignBridgeEdge(G[u][i].fi, u, curLevel + 1, forestId, G[u][i].se);
		if(highestLevelReached[G[u][i].fi] > level[u]) {
//			printf("HAFSDFS %d %d %d %d\n",u, G[u][i].fi, highestLevelReached[u], highestLevelReached[G[u][i].fi]);
			isBridge[G[u][i].se] = true;
		}
		else {
			highestLevelReached[u] = min(highestLevelReached[G[u][i].fi], highestLevelReached[u]);
		}
	}
}

void init() {
	memset(dp, -1, sizeof(dp));
	memset(forest, -1, sizeof(forest));
	memset(jumpUp, -1, sizeof(jumpUp));
	memset(jumpDown, -1, sizeof(jumpDown));
	forestCnt = 0;
}

void createBridgeTree(int u, int bridgeComponentId, int par = -1) {
	BC[u] = bridgeComponentId;
	vis2[u] = 1;
	for(int i = 0 ; i < G[u].size() ; i++) {
		if(G[u][i].fi == par)	continue;
		if(vis2[G[u][i].fi]) {
			continue;
		}
		if(isBridge[G[u][i].se]) {
//			printf("ASDS @@@@ %d %d\n",G[u][i].fi,bridgeComponentId);
			Gaux[G[u][i].fi].pb(p(bridgeComponentId, G[u][i].se));
			Gaux[bridgeComponentId].pb(p(G[u][i].fi, G[u][i].se));
			q.push(G[u][i].fi);
		}
		else {
			createBridgeTree(G[u][i].fi, bridgeComponentId, u);
		}
	}
}

void dfs(int u, int par = -1, int levelCnt = 0) {
//	printf("QQQ %d %d\n", u , levelCnt);
	counteris++;
	level[u] = levelCnt;
	dp[u][0] = par;
	for(int i = 0 ; i < Gaux[u].size() ; i++) {
		if(Gaux[u][i].fi == par)	continue;
		dfs(Gaux[u][i].fi, u, levelCnt + 1);
	}
}

int LCA(int u, int v) {
	if(u == v) 	return u;
	if(level[u] > level[v]) swap(u, v);
	int diff = level[v] - level[u];
	for(int i = LOGN - 1; i >= 0 ; i--) {
		if((diff >> i) & 1) {
			v = dp[v][i];
		}
	}
	if(u == v)	return u;
	for(int i = LOGN - 1 ; i >= 0 ; i--) {
		if(dp[u][i] != -1 && dp[u][i] != dp[v][i])
			u = dp[u][i], v = dp[v][i];
	}
	return dp[u][0];
}
int down[MAX];
int up[MAX];
int ans = 1;
void fin(int p, int v)
{
	for (int i = 0; i < Gaux[v].size(); i++)
	{
		int u = Gaux[v][i].fi;
		if (u == p)
			continue;
		fin(v, u);
		down[v] += down[u];
		up[v] += up[u];
	}
//	printf("ASD %d %d %d\n",v,down[v],up[v]);
	if (down[v] > 0 && up[v] > 0)
		ans = false;
}

int main() {
	init();
	int N, M, Q;
	int flag = 0;
	int u,v;
	scanf("%d%d%d",&N, &M, &Q);
	for(int i = 0 ; i < M ; i++) {
		scanf("%d%d",&u,&v);
		if(u == 77 && i == 0)
			flag = 1;
		edgeFirst[i] = u;
		edgeFirst[i] = v;
		G[u].pb(p(v, i));
		G[v].pb(p(u, i));
	}

	for(int i = 1 ; i <= N ; i++)
	{
		if(forest[i] == -1)
			assignBridgeEdge(i, -1, 0, i);
		else
			continue;
//		for(int j = 1 ; j <= N ; j++)
//			printf("PPPPPP %d : %d\n", j, highestLevelReached[j]);
		while(q.size())
			q.pop();
		q.push(i);
		while(q.size()) {
			int u = q.front();
//			printf("HEYASF %d\n",u);
			q.pop();
			createBridgeTree(u, u);
		}
		// Bridge Tree created now comes the par to assign LCA and dfs....
		dfs(i);
	}

	for(int i = 1 ; i < LOGN ;  i++) {
		for(int j = 1 ; j <= N ; j++) {
			if(dp[j][i-1] == -1)	continue;
			dp[j][i] = dp[dp[j][i-1]][i-1];
		}
	}
	/*for(int i = 1 ; i <= N ; i++) {
		printf("Forest %d : %d\n", i, forest[i]);
	}*/
//	if(flag == 1)
//		printf("PP %d\n",counteris);
	while(Q--) {

		scanf("%d%d",&u,&v);
		if(forest[u] != forest[v]) {
			printf("No\n");
			return 0;
		}
		u = BC[u];
		v = BC[v];
		if(u == v)	continue;
		int lca = LCA(u, v);
//		printf("HEY %d %d %d\n",u, v, lca);
		up[u]++;
		up[lca]--;
		down[v]++;
		down[lca]--;
	}
	for(int i = 1 ; i <= N ; i++) {
		if(dp[i][0] == -1)
			fin(i,i);
	}
	if(ans)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
const int MAX = 200005;
vector<int> adj[MAX];
int from[MAX], to[MAX], low[MAX], d[MAX], color[MAX], cc[MAX], par[20][MAX];
bool iscut[MAX], mark[MAX], ans = true;
void dfs(int p, int v)
{
	mark[v] = true;
	for (int i = 0; i < adj[v].size(); i++)
	{
		int id = adj[v][i];
		if (id == p)
			continue;
		int u = from[id] + to[id] - v;
		if (mark[u])
		{
			if (d[low[v]] > d[u])
				low[v] = u;
		}
		else
		{
			d[u] = d[v] + 1;
			dfs(id, u);
			if (d[low[u]] > d[v])
				iscut[id] = true;
			if (d[low[v]] > d[low[u]])
				low[v] = low[u];
		}
	}
}
void go(int v, int c)
{
	color[v] = c;
	for (int i = 0; i < adj[v].size(); i++)
	{
		int id = adj[v][i];
		if (iscut[id])
			continue;
		int u = from[id] + to[id] - v;
		if (color[u] == -1)
			go(u, c);
	}
}
int iscounter = 0;
void init(int p, int v, int c)
{
	iscounter++;
	cc[v] = c;
	par[0][v] = p;
	for (int i = 1; i < 20; i++)
		par[i][v] = par[i - 1][par[i - 1][v]];
	for (int i = 0; i < adj[v].size(); i++)
	{
		int u = adj[v][i];
		if (u == p)
			continue;
		d[u] = d[v] + 1;
		init(v, u, c);
	}
}
int get_parent(int v, int k)
{
	for (int i = 0; i < 20; i++)
		if ((1 << i) & k)
			v = par[i][v];
	return v;
}
int lca(int u, int v)
{
	if (d[u] < d[v])
		swap(u, v);
	u = get_parent(u, d[u] - d[v]);
	if (u == v)
		return u;
	for (int i = 19; i >= 0; i--)
		if (par[i][u] != par[i][v])
		{
			u = par[i][u];
			v = par[i][v];
		}
	return par[0][v];
}
int down[MAX], up[MAX];
void fin(int p, int v)
{
	for (int i = 0; i < adj[v].size(); i++)
	{
		int u = adj[v][i];
		if (u == p)
			continue;
		fin(v, u);
		down[v] += down[u];
		up[v] += up[u];
	}
	if (down[v] > 0 && up[v] > 0)
		ans = false;
}
int main()
{
	ios::sync_with_stdio(false);
	memset(color, -1, sizeof(color));
	for (int i = 0; i < MAX; i++)
		low[i] = i;
	int n, m, q;
	cin >> n >> m >> q;
	int flag = 0;
	for (int i = 0; i < m; i++)
	{
		cin >> from[i] >> to[i];
		if(i == 0 && from[i] == 77)
			flag = 1;
		from[i]--;
		to[i]--;
		adj[from[i]].push_back(i);
		adj[to[i]].push_back(i);
	}
	for (int i = 0; i < n; i++)
		if (!mark[i])
			dfs(-1, i);
	int c = 0;
	for (int i = 0; i < n; i++)
		if (color[i] == -1)
			go(i, c++);
	for (int i = 0; i < n; i++)
		adj[i].clear();
	for (int i = 0; i < m; i++)
		if (iscut[i])
		{
			adj[color[from[i]]].push_back(color[to[i]]);
			adj[color[to[i]]].push_back(color[from[i]]);
		}
	memset(cc, -1, sizeof(cc));
	memset(d, 0, sizeof(d));
	n = c;
	c = 0;
	for (int i = 0; i < n; i++)
		if (cc[i] == -1)
			init(i, i, c++);
	if(flag)
		printf("HEY %d\n",iscounter);
	while (q--)
	{
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		u = color[u];
		v = color[v];
		if (cc[u] != cc[v])
			ans = false;
		else
		{
			int p = lca(u, v);
			up[u]++;
			up[p]--;
			down[p]--;
			down[v]++;
		}
	}
	for (int i = 0; i < n; i++)
		if (par[0][i] == i)
			fin(i, i);
	if (ans)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


#include "bits/stdc++.h"

using namespace std;

#define MAX 210005
#define fi first
#define se second
#define pb push_back
#define UP 1
#define DOWN 2
#define LOGN 20
typedef pair<int, int> p;

std::vector<p> G[MAX];
std::vector<p> Gaux[MAX];
int forest[MAX];
int forestCnt;
int highestLevelReached[MAX];
int level[MAX];
int isBridge[MAX];
int bridgeComponentId;
int direction[MAX];
int edgeFirst[MAX];
int edgeSecond[MAX];
int dp[MAX][LOGN];
int directiondp[MAX][LOGN];
int vis[MAX];
int vis2[MAX];
int BC[MAX];
int jumpUp[MAX];
int jumpDown[MAX];
int counteris = 0;
queue<int> q;

void assignBridgeEdge(int u, int par = -1, int curLevel = 0, int forestId = 1, int edgeId = -1) {
//	printf("HEY %d %d\n",u, par);
	forest[u] = forestId;
	level[u] = curLevel;
	vis[u] = 1;
	highestLevelReached[u] = curLevel;
	for(int i = 0 ; i < G[u].size() ; i++) {
		if(G[u][i].fi == par && G[u][i].se == edgeId)	continue;
		if(vis[G[u][i].fi]){
			highestLevelReached[u] = min(highestLevelReached[u], level[G[u][i].fi]);
			continue;
		}
		assignBridgeEdge(G[u][i].fi, u, curLevel + 1, forestId, G[u][i].se);
		if(highestLevelReached[G[u][i].fi] > level[u]) {
//			printf("HAFSDFS %d %d %d %d\n",u, G[u][i].fi, highestLevelReached[u], highestLevelReached[G[u][i].fi]);
			isBridge[G[u][i].se] = true;
		}
		else {
			highestLevelReached[u] = min(highestLevelReached[G[u][i].fi], highestLevelReached[u]);
		}
	}
}

void init() {
	memset(dp, -1, sizeof(dp));
	memset(forest, -1, sizeof(forest));
	memset(jumpUp, -1, sizeof(jumpUp));
	memset(jumpDown, -1, sizeof(jumpDown));
	forestCnt = 0;
}

void createBridgeTree(int u, int bridgeComponentId, int par = -1) {
	BC[u] = bridgeComponentId;
	vis2[u] = 1;
	for(int i = 0 ; i < G[u].size() ; i++) {
		if(G[u][i].fi == par)	continue;
		if(vis2[G[u][i].fi]) {
			continue;
		}
		if(isBridge[G[u][i].se]) {
//			printf("ASDS @@@@ %d %d\n",G[u][i].fi,bridgeComponentId);
			Gaux[G[u][i].fi].pb(p(bridgeComponentId, G[u][i].se));
			Gaux[bridgeComponentId].pb(p(G[u][i].fi, G[u][i].se));
			q.push(G[u][i].fi);
		}
		else {
			createBridgeTree(G[u][i].fi, bridgeComponentId, u);
		}
	}
}

void dfs(int u, int par = -1, int levelCnt = 0) {
//	printf("QQQ %d %d\n", u , levelCnt);
	counteris++;
	level[u] = levelCnt;
	dp[u][0] = par;
	for(int i = 0 ; i < Gaux[u].size() ; i++) {
		if(Gaux[u][i].fi == par)	continue;
		dfs(Gaux[u][i].fi, u, levelCnt + 1);
	}
}

int LCA(int u, int v) {
	if(u == v) 	return u;
	if(level[u] > level[v]) swap(u, v);
	int diff = level[v] - level[u];
	for(int i = LOGN - 1; i >= 0 ; i--) {
		if((diff >> i) & 1) {
			v = dp[v][i];
		}
	}
	if(u == v)	return u;
	for(int i = LOGN - 1 ; i >= 0 ; i--) {
		if(dp[u][i] != -1 && dp[u][i] != dp[v][i])
			u = dp[u][i], v = dp[v][i];
	}
	return dp[u][0];
}

int main() {
	init();
	int N, M, Q;
	int flag = 0;
	int u,v;
	scanf("%d%d%d",&N, &M, &Q);
	for(int i = 0 ; i < M ; i++) {
		scanf("%d%d",&u,&v);
		if(u == 77 && i == 0)
			flag = 1;
		edgeFirst[i] = u;
		edgeFirst[i] = v;
		G[u].pb(p(v, i));
		G[v].pb(p(u, i));
	}

	for(int i = 1 ; i <= N ; i++)
	{
		if(forest[i] == -1)
			assignBridgeEdge(i, -1, 0, i);
		else
			continue;
//		for(int j = 1 ; j <= N ; j++)
//			printf("PPPPPP %d : %d\n", j, highestLevelReached[j]);
		while(q.size())
			q.pop();
		q.push(i);
		while(q.size()) {
			int u = q.front();
//			printf("HEYASF %d\n",u);
			q.pop();
			createBridgeTree(u, u);
		}
		// Bridge Tree created now comes the par to assign LCA and dfs....
		dfs(i);
	}

	for(int i = 1 ; i < LOGN ;  i++) {
		for(int j = 1 ; j <= N ; j++) {
			if(dp[j][i-1] == -1)	continue;
			dp[j][i] = dp[dp[j][i-1]][i-1];
		}
	}
	/*for(int i = 1 ; i <= N ; i++) {
		printf("Forest %d : %d\n", i, forest[i]);
	}*/
	if(flag == 1)
		printf("PP %d\n",counteris);
	while(Q--) {

		scanf("%d%d",&u,&v);
		if(forest[u] != forest[v]) {
			printf("No\n");
			return 0;
		}
		u = BC[u];
		v = BC[v];
		if(u == v)	continue;
		int lca = LCA(u, v);
//		printf("HEY %d %d %d %d %d\n",u,v,lca,level[u], level[v]);
		while(level[u] > level[lca]) {
//			printf("YY %d %d\n",u,lca);
			if(jumpDown[u] != -1) {
				printf("No\n");
				return 0;
			}
			if(jumpUp[u] == -1) {
				jumpUp[u] = lca;
				u = dp[u][0];
			}
			else {
				u = jumpUp[u];
				jumpUp[u] = lca;
			}
		}/*
		if(level[u] <= level[lca]) {
			printf("No\n");
			return 0;
		}*/

		while(level[v] > level[lca]) {
//			printf("YYAA %d %d\n",v,lca);
			if(jumpUp[v] != -1) {
				printf("No\n");
				return 0;
			}
			if(jumpDown[v] == -1) {
				jumpDown[v] = lca;
				v = dp[v][0];
			}
			else {
				v = jumpDown[v];
				jumpDown[v] = lca;
			}
		}
		/*if(level[v] <= level[lca]) {
			printf("No\n");
			return 0;
		}*/
	}

	printf("Yes\n");
	return 0;
}