-
Notifications
You must be signed in to change notification settings - Fork 3
/
A_A_Variety_of_Operations.cpp
110 lines (98 loc) · 2.34 KB
/
A_A_Variety_of_Operations.cpp
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
107
108
109
110
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define all(arr) arr.begin(),arr.end()
#define f first
#define s second
#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define nl cout<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cout<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define MOD 1000000007
#define space ' '
#define kick(t) cout << "Case #" << t+1 << ":" << endl;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
template <typename T>
void input(vector<T> &arr,lli n) {
T temp;
for(lli i=0;i<n;i++) cin>>temp, arr.push_back(temp);
}
template <typename T>
void output(vector<T> arr) {
for(auto x:arr) cout<<x<<" ";
cout<<endl;
}
template <typename T>
void input_set(set<T> &arr,lli n) {
T temp;
for(lli i=0;i<n;i++) cin>>temp, arr.insert(temp);
}
lli mul(lli a, lli b) {
return (a%MOD*b%MOD)%MOD;
}
lli power(lli a,lli b) {
lli ans = 1;
while(b > 0) {
if(b&1)
ans = mul(ans, a);
a = mul(a,a);;
b >>= 1;
}
return ans;
}
void solve(int testcase) {
int c,d;
cin >> c >> d;
if(abs(c-d)%2==1){
cout << -1 << endl;
}
else if(c==d && c==0){
cout << 0 << endl;
}
else if(c==d && c!=0){
cout << 1 << endl;
}
else{
cout << 2 << endl;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
lli testcases=1;
cin >> testcases;
for(int testcase=0; testcase<testcases; testcase++) {
solve(testcase);
}
}