//satyaki3794 #include #define ff first #define ss second #define pb push_back #define MOD (1000000007LL) #define LEFT(n) (2*(n)) #define RIGHT(n) (2*(n)+1) using namespace std; typedef long long ll; typedef pair ii; typedef pair iii; ll pwr(ll base, ll p, ll mod=MOD){ ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans; } ll gcd(ll a, ll b){ if(b == 0) return a; return gcd(b, a%b); } int r, c, k; ii tunnel[25][25]; char arr[25][25]; double prob[25][25][2]; bool valid(int i, int j){ return i>=0 && i=0 && j>r>>c>>k; for(int i=0;i>arr[i]; while(k--){ int x1, y1, x2, y2; cin>>x1>>y1>>x2>>y2; tunnel[x1-1][y1-1] = ii(x2-1, y2-1); tunnel[x2-1][y2-1] = ii(x1-1, y1-1); } // for(int i=0;i