#include #define rep(i, a, n) for(int i = a; i < n; i++) #define int long long using namespace std; typedef pair P; const int mod = 1000000007; const int INF = 1e18; signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; map mp; rep(i, 0, n){ int k, l, d; cin >> k >> l >> d; int now = l; rep(j, 0, k){ mp[now]++; now += (1LL << d); } } for(auto i : mp){ if(i.second % 2){ cout << i.first << endl; return 0; } } }