# Codeforces869e the untended antiquity

Posted by yjjr's blog on February 6, 2018

Koyomi is helping Oshino, an acquaintanceof his, to take care of an open space around the abandoned Eikou Cram Schoolbuilding, Oshino's makeshift residence.

The space is represented by a rectangulargrid ofn × m cells, arranged into n rows and m columns. Thec-thcell in the r-th row is denoted by (r, c).

Oshino places and removes barriers aroundrectangular areas of cells. Specifically, an action denoted by "1r1c1 r2 c2" meansOshino's placing barriers around a rectangle with two corners being (r1, c1)and (r2, c2) and sides parallel to squaressides. Similarly, "2 r1 c1r2c2" means Oshino's removing barriers around therectangle. Oshino ensures that no barriers staying on the ground share anycommon points, nor do they intersect with boundaries of then × m area.

Sometimes Koyomi tries to walk from onecell to another carefully without striding over barriers, in order to avoiddamaging various items on the ground. "3r1 c1r2 c2" means that Koyomi tries to walkfrom (r1, c1) to (r2, c2)without crossing barriers.

And you're here to tell Koyomi thefeasibility of each of his attempts.

Input

The first line of input contains threespace-separated integersn, m and q (1 ≤ n, m ≤ 2 500, 1 ≤ q ≤ 100 000) — the number of rows and columns inthe grid, and the total number of Oshino and Koyomi's actions, respectively.

The following q lines each describesan action, containing five space-separated integerst, r1,c1, r2,c2 (1 ≤ t ≤ 3, 1 ≤ r1, r2 ≤ n, 1 ≤ c1, c2 ≤ m) — the type and two coordinates of an action. Additionally, thefollowing holds depending on the value of t:

• If t = 1: 2 ≤ r1 ≤ r2 ≤ n - 1, 2 ≤ c1 ≤ c2 ≤ m - 1;
• If t = 2: 2 ≤ r1 ≤ r2 ≤ n - 1, 2 ≤ c1 ≤ c2 ≤ m - 1, the specified group of barriers exist on the ground before the removal.
• If t = 3: no extra restrictions.

Output

For each of Koyomi's attempts (actions witht = 3), output one line — containing "Yes"(without quotes) if it's feasible, and "No" (without quotes)otherwise.

Examples

Input

5 6 5
1 2 2 4 5
1 3 3 3 3
3 4 4 1 1
2 2 2 4 5
3 1 1 4 4

Output

No
Yes

Input

2500 2500 8
1 549 1279 1263 2189
1 303 795 1888 2432
1 2227 622 2418 1161
3 771 2492 1335 1433
1 2017 2100 2408 2160
3 48 60 798 729
1 347 708 1868 792
3 1940 2080 377 1546

Output

No
Yes
No

Note

For the first example, the situations ofKoyomi's actions are illustrated below.

And else 这题的卡常很恶心啊，建议使用读入优化，数组不要开大了，否则绝对会TLE啊

Code

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int maxn=2506;
int was[maxn][maxn];

{
int f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}

int main()
{
rep(i,1,q){
if(t==1)rep(r,r1,r2){was[r][c1]=i;was[r][c2+1]=-1;}
else if(t==2)rep(r,r1,r2)was[r][c1]=was[r][c2+1]=0;
else{
int st=0,res1=0,res2=0;
dep(i,c1,0)
if(was[r1][i]>0)
if(st==0){res1=was[r1][i];break;}
else st++;
else if(was[r1][i]<0)st--;
st=0;
dep(i,c2,0)
if(was[r2][i]>0)
if(st==0){res2=was[r2][i];break;}
else st++;
else if(was[r2][i]<0)st--;
printf("%s",res1==res2?"Yes\n":"No\n");
}
}
return 0;
}