#include using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef vector vi; #define pb push_back #define mp make_pair int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); map a; a["golf"] = "bob"; a["fishing"] = "alice"; a["hockey"] = "charlie"; int n; cin >> n; string _; rep(i, 0, n) { string s, t; cin >> s >> _ >> _ >> _ >> t; if (a[t] == s) { cout << s << " already has " << t << endl; } else { cout << s << " borrows " << t << " from " << a[t] << endl; a[t] = s; } } }