2021-11-19 09:01:13 +00:00
|
|
|
#include <bits/stdc++.h>
|
2020-10-13 13:08:38 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
map<int, map<int, int> > m;
|
|
|
|
int n, q, t, i, j, k;
|
|
|
|
cin >> n >> q;
|
2021-11-19 09:01:13 +00:00
|
|
|
while (q--) {
|
2020-10-13 13:08:38 +00:00
|
|
|
cin >> t >> i >> j;
|
2021-11-19 09:01:13 +00:00
|
|
|
if (t == 1) {
|
2020-10-13 13:08:38 +00:00
|
|
|
cin >> k;
|
2021-11-19 09:01:13 +00:00
|
|
|
if (k == 0) {
|
|
|
|
if (m.count(i) && m[i].count(j)) {
|
2020-10-13 13:08:38 +00:00
|
|
|
m[i].erase(k);
|
2021-11-19 09:01:13 +00:00
|
|
|
if (m[i].empty()) {
|
2020-10-13 13:08:38 +00:00
|
|
|
m.erase(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
m[i][j] = k;
|
|
|
|
}
|
2021-11-19 09:01:13 +00:00
|
|
|
} else if (t == 2) {
|
2020-10-13 13:08:38 +00:00
|
|
|
cout << m[i][j] << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|