/*
TASK:moves
LANG:C++
*/
#include<iostream>
using namespace std;
class officer{
      public:
      int a,b;
      bool operator==(officer c){
           if(a%2==b%2 && c.a%2==c.b%2) return true;
           if(a%2!=b%2 && c.a%2!=c.b%2) return true;
           return false;}
           };
int main(){
    int m,n,k,a[128];
    cin >> m >> n;
    cin >> k;
    for(int i=0;i<k;i++){
            officer x,y;
            cin >> x.a >> x.b >> y.a >> y.b;
            a[i]=!(x==y);}
    for(int i=0;i<k;i++) cout << a[i];
    cout << endl;
    return 0;
}
