#include<iostream>
#include<vector>
#include<unordered_map>
// setAll功能的哈希表
// 测试链接 : https://www.nowcoder.com/practice/7c4559f138e74ceb9ba57d76fd169967
// 请同学们务必参考如下代码中关于输入、输出的处理
// 这是输入输出处理效率很高的写法
class SetAllHashMap {
public:
std::unordered_map<int,std::vector<int>> s;
int setAllValue;
int setAllTime;
int cnt;
SetAllHashMap() {
// 初始化
cnt = 0;
setAllTime = -1;
setAllValue = 0;
}
int get(int k) {
if (!s.count(k)) {
return -1;
}
std::vector<int> value = s[k];
if (value[1] > setAllTime) return value[0];
else return setAllValue;
}
void put(int k, int v) {
if (s.count(k)) {
std::vector<int> value = s[k];
value[0] = v;
value[1] = cnt++;
s[k] = value;
} else {
s[k] = {v, cnt++};
}
}
void setAll(int v) {
setAllValue = v;
setAllTime = cnt++;
}
};
int main() {
int n, op, a, b;
while (std::cin >> n) {
SetAllHashMap hash_map;
for (int i = 0; i < n; i++) {
std::cin >> op;
if (op == 1) {
std::cin >> a >> b;
hash_map.put(a, b);
} else if (op == 2) {
std::cin >> a;
std::cout << hash_map.get(a) << std::endl;
} else {
std::cin >> a;
hash_map.setAll(a);
}
}
}
return 0;
}