#include #include #include using namespace std; using boost::container::flat_set; int main() { int n, m; cin >> n >> m; vector a(n); for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < m; ++i) { int t, l, r; cin >> t >> l >> r; if (t == 1) { int x, y; cin >> x >> y; for (int j = l; j <= r; ++j) { if (a[j] == x) a[j] = y; } } else { int k; cin >> k; flat_set b(a.begin(), a.end()); // ソート済み重複なし int s = 0; for (int c : b) { if (k + s < c) { cout << k + s << endl; goto NEXT; } s++; } cout << k + s << endl; NEXT:; } } return 0; }