n = int(input())
l=[ ]
for i in range(n ):
row_1 = input().split()
row_2 = input().split()
kolli = [int(i) for i in row_1 + row_2]
sefr , yek = 0 , 0
for i in kolli:
if i == 0:
sefr += 1
else:
yek += 1
if sefr == 4 :
l.append(0)
elif yek == 2 or yek == 1 or yek == 3:
l.append(1)
else:
l.append(2)
for i in l :
print(i)
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int x=2,y=2;
int a[x][y];
for(int i=0;i<x;i++)
{
for(int j=0;j<y;j++)
{
cin>>a[i][j];
}
}
int cnt=0;
for(int i=0;i<x;i++)
{
for(int j=0;j<y;j++)
{
if(a[0][0]==0&&a[0][1]==0&&a[1][0]==0&&a[1][1]==0)
{
cnt=0;
break;
}
else if(a[0][0]==1&&a[0][1]==1&&a[1][0]==1&&a[1][1]==1)
{
cnt=2;
break;
}
else
{
cnt=1;
break;
}
}
}
if(cnt)
{
cout<<cnt<<endl;
}
else
cout<<0<<endl;
}
}
137. Single Number II | 130. Surrounded Regions |
129. Sum Root to Leaf Numbers | 120. Triangle |
102. Binary Tree Level Order Traversal | 96. Unique Binary Search Trees |
75. Sort Colors | 74. Search a 2D Matrix |
71. Simplify Path | 62. Unique Paths |
50. Pow(x, n) | 43. Multiply Strings |
34. Find First and Last Position of Element in Sorted Array | 33. Search in Rotated Sorted Array |
17. Letter Combinations of a Phone Number | 5. Longest Palindromic Substring |
3. Longest Substring Without Repeating Characters | 1312. Minimum Insertion Steps to Make a String Palindrome |
1092. Shortest Common Supersequence | 1044. Longest Duplicate Substring |
1032. Stream of Characters | 987. Vertical Order Traversal of a Binary Tree |
952. Largest Component Size by Common Factor | 212. Word Search II |
174. Dungeon Game | 127. Word Ladder |
123. Best Time to Buy and Sell Stock III | 85. Maximal Rectangle |
84. Largest Rectangle in Histogram | 60. Permutation Sequence |