
#include <bits/stdc++.h>using namespace std;//#define int long long
#define endl '\n'
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;
using PII = pair<int,int>; const int N=1e5+5;void solve() {int n;cin >> n;string t,s;cin>>t;bool f=0;for(int i=1;i<=n;i++){cin>>s;if(s==t){cout<<i<<endl;f=1;}}if(!f){cout<<-1<<endl;}
}signed main() {ios::sync_with_stdio(false);cin.tie(nullptr);int t;cin >> t;while (t--) {solve();}return 0;
}/*
* _oo0oo_
* o8888888o
* 88" . "88
* (| -_- |)
* 0\ = /0
* ___/`---'\___
* .' \\| |// '.
* / \\||| : |||// \
* / _||||| -:- |||||- \
* | | \\\ - /// | |
* | \_| ''\---/'' |_/ |
* \ .-\__ '-' ___/-. /
* ___'. .' /--.--\ `. .'___
* ."" '< `.___\_<|>_/___.' >' "".
* | | : `- \`.;`\ _ /`;.`/ - ` : | |
* \ \ `_. \_ __\ /__ _/ .-` / /
* =====`-.____`.___ \_____/___.-`___.-'=====
* `=---='
*
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* 佛祖保佑 永不宕机 永无BUG
*/
个数用哈希表存比较好(但是map过了)
#include <bits/stdc++.h>using namespace std;//#define int long long
#define endl '\n'
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;
using PII = pair<int,int>; const int N=1e5+5;void solve() {int n;cin >> n;vector<int>a(3);map<int,int>mp;for(int i=1;i<=n;i++){cin>>a[0]>>a[1]>>a[2];sort(a.begin(),a.end());do{if((a[0]-a[1])%a[2]==0){if((a[0]-a[1])/a[2]>=0)mp[(a[0]-a[1])/a[2]]++;}}while(next_permutation(a.begin(),a.end()));for(auto x:mp){if(x.second>=n){cout<<x.first<<endl;}}}
}signed main() {ios::sync_with_stdio(false);cin.tie(nullptr);int t;cin >> t;while (t--) {solve();}return 0;
}