/*
TASK:MOVES
LANG:C++
*/
#include<iostream>
using namespace std;
int main()
{
    int m,n,k,x1,x2,y1,y2,i;
    cin>>m>>n>>k;
    for(i=1;i<=k;i++){cin>>x1>>y1>>x2>>y2;
                  if((x1+y1)%2==(x2+y2)%2)cout<<"0";
                  else cout<<"1";
                  }
    cout<<"\n";              
    return 0;
}                                  
