#include #include #include #include #include #include #include #include #include #include #include #include #include #define pii pair #define pdd pair #define x first #define y second #define mp make_pair #define pb push_back #define INF 1000000005 #define NMAX (1 << 16) #define LMAX (1 << 8) #define HMAX (1 << 8) using namespace std; int n, m, S[LMAX], A[NMAX]; int a, b, c, last; int get2(int x) { if (S[x] == 0) return 0; if (S[x] == HMAX) return 1; return -1; } int get1(int x) { int res = get2(x >> 8); return res != -1 ? res : A[x]; } int main() { //~ freopen("input", "r", stdin); scanf("%d%d", &n, &m); n--; last = n >> 8; int type; for (int i = 1; i <= m; i++) { scanf("%d", &type); if (type == 1) { scanf("%d%d%d", &a, &b, &c); a--; b--; int x = a >> 8, y = b >> 8; for (int j = x + 1; j <= y - 1; j++) S[j] = c * HMAX; int col = get2(x); if (col != -1) { for (int j = (x << 8); j < ((x + 1) << 8); j++) A[j] = col; } for (int j = a; j < ((x + 1) << 8) && j <= b; j++) { S[x] -= A[j]; A[j] = c; S[x] += c; } if (x < y) { col = get2(y); if (col != -1) { for (int j = (y << 8); j < ((y + 1) << 8); j++) A[j] = col; } for (int j = (y << 8); j <= b; j++) { S[y] -= A[j]; A[j] = c; S[y] += c; } } } else { scanf("%d", &a); a--; int col = get1(a); int x = a >> 8; for (int j = a; j >= (x << 8); j--) if (get1(j) == col) b = j; else break ; if (b == (x << 8)) { for (int j = x - 1; j >= 0; j--) if (get2(j) == col) b -= HMAX; else { for (int k = ((j + 1) << 8) - 1; k >= (j << 8); k--) if (get1(k) == col) b = k; else break ; break ; } } printf("%d %d ", col, b + 1); for (int j = a; j < ((x + 1) << 8) && j <= n; j++) if (get1(j) == col) b = j; else break ; if (b == ((x + 1) << 8) - 1) { for (int j = x + 1; j <= last; j++) if (get2(j) == col) b += HMAX; else { for (int k = (j << 8); k < ((j + 1) << 8); k++) if (get1(k) == col) b = k; else break ; break ; } } b = min(b, n); printf("%d\n", b + 1); } } return 0; }