#include #include #include #include #include #include #include #include #include #include using namespace std; struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<> t; for (int i=0; i> a >> b >> c; if ((a= 3) { cout << 3 << endl; continue; } if (a > c) swap(a,c); if (a == 1 && b == 2) { cout << -1 << endl; continue; } if (a != 1) { ans = min(ans, abs(b-a) + 1); } ans = min(ans, abs(b-c) + 1 + (b-1==a? 1 : 0)); cout << ans << endl; } }