
{% link 洛谷文章链接,xyx404,https://www.luogu.com.cn/article/jfgn4oek %}
思路: #
通过分析,可以发现:
- 当 $n$ 和 $m$ 中有一个为 $1$ 时,只用一条线就可以,答案为 $1$。
- 当 $n$ 和 $m$ 中没有一个为 $1$ 时,当 $n
如果还是无法理解,可以看看图片。

代码: #
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define itn int
#define ull unsigned long long
int T;
int main(){
cin>>T;
while(T--){
int n,m;
cin>>n>>m;
if(n==1||m==1){
cout<<"1\n";
}
else{
cout<<min(n,m)+1<<"\n";
}
}
return 0;
}