-
Notifications
You must be signed in to change notification settings - Fork 2
/
que2.txt
106 lines (87 loc) · 1.76 KB
/
que2.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define inf LLONG_MAX
ll isPrime(int n)
{
// Corner cases
if (n <= 1)
return 1;
if (n <= 3)
return 2;
// This is checked so that we can skip
// middle five numbers in below loop
if (n % 2 == 0 || n % 3 == 0)
return 1;
for (int i = 5; i * i <= n; i = i + 6)
if (n % i == 0 || n % (i + 2) == 0)
return 1;
return 2;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007;
return res; }
int gcd(int a, int b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
ll findlcm(ll arr[], int n)
{
ll ans = arr[0];
for (int i = 1; i < n; i++)
ans = (((arr[i] * ans)) /
(gcd(arr[i], ans)));
return ans;
}
bool sortbysec(const pair<pair<string,int>,int> &a,
const pair<pair<string,int>,int> &b)
{
if(a.first.first==b.first.first)
return a.first.second > b.first.second;
return (a.first.first < b.first.first);
}
bool checkValidity(ll a, ll b, ll c)
{
// check condition
if (a + b <= c || a + c <= b || b + c <= a)
return false;
else
return true;
}
int main()
{
fast;
ll t;
cin>>t;
while(t--)
{
int n , m;
cin >> n >> m;
int a[n][2][2];
for(int i = 0; i < n; ++i) {
for(int j = 0; j < 2; ++j) {
for(int z = 0; z < 2; ++z) {
cin >> a[i][j][z];
}
}
}
if(m % 2) {
cout << "NO\n";
}
else{
for(int i = 0; i < n; ++i) {
if(a[i][0][1] == a[i][1][0]) {
cout << "YES\n";
goto x;
}
}
cout << "NO\n";
x:
cout<<"";
}
}
return 0;
}