import java.util.*;
import java.lang.*;
import java.io.*;
class Ideone {
public static void main
(String[] args
) {
//create an DB for online and reged users
Scanner in
= new Scanner
(System.
in);
//a number of queries
int n = in.nextInt();
for (int i = 0; i < n; i++){
//command
s = in.next();
if (s.equals("register")){
log = in.next(); //login
pass = in.next(); //password
if (DB.containsKey(log)){ //login in DB?
out.println("fail: user already exists");
out.flush();
}
else {
DB.put(log, pass);
out.println("success: new user added");
out.flush();
}
}
if (s.equals("login")){
log = in.next();
pass = in.next();
if (DB.containsKey(log)){ //if user is reg
if (pass.equals(DB.get(log))) { //if the password is well
if (!DBin.contains(log)) { //online?
DBin.add(log);
out.println("success: user logged in");
out.flush();
}
//Errors
else {
out.println("fail: already logged in");
out.flush();
}
}
else {
out.println("fail: incorrect password");
out.flush();
}
}
else {
out.println("fail: no such user");
out.flush();
}
}
if (s.equals("logout")){
log = in.next();
if (!DB.containsKey(log)) { //unreg user can't logout... unfortunately.
out.println("fail: no such user");
out.flush();
}
else {
if (!DBin.contains(log)){ //so offline user does
out.println("fail: already logged out");
out.flush();
}
else {
DBin.remove(log);
out.println("success: user logged out");
out.flush();
}
}
}
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgogY2xhc3MgSWRlb25lIHsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB7CgkJCgkJLy9jcmVhdGUgYW4gREIgZm9yIG9ubGluZSBhbmQgcmVnZWQgdXNlcnMKCQlNYXAgREIgPSBuZXcgSGFzaE1hcDxTdHJpbmcsIFN0cmluZz4gKCk7IAoJCUhhc2hTZXQgPFN0cmluZz4gREJpbiA9IG5ldyBIYXNoU2V0IDxTdHJpbmc+ICgpOwoJCQoJCVNjYW5uZXIgaW4gPSBuZXcgU2Nhbm5lciAoU3lzdGVtLmluKTsKCQlQcmludFdyaXRlciBvdXQgPSBuZXcgUHJpbnRXcml0ZXIoU3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