#include<iostream> #include<cstdlib> #include<cstdio> usingnamespacestd; inlineintread() { int f = 1, x = 0; char ch;
do{ ch = getchar(); if (ch == '-') f = -1; }while(ch < '0' || ch > '9'); do{ x = x * 10 + ch - '0'; ch = getchar(); }while(ch >= '0' && ch <= '9'); return f * x; } constint N = 2e5;
int tt; int n; int tot; int a[N + 1];
intmain() { tt = read();
while (tt--) { n = read(); int tot = 0; for (int i = 1; i <= n; i++) { a[i] = read(); if (a[i] != a[i - 1]) tot++; } if (tot == 1) { printf("1\n"); for (int i = 1; i <= n; i++) printf("1 "); printf("\n"); continue; } if (!(tot & 1)) { printf("2\n1 "); int now = 1; for (int i = 2; i <= n; i++) { if (a[i] != a[i - 1]) { if (now == 1) now = 2; else now = 1; } printf("%d ", now); } printf("\n"); } else { if (a[1] == a[n]) { printf("2\n1 "); int now = 1; for (int i = 2; i <= n; i++) { if (a[i] != a[i - 1]) { if (now == 1) now = 2; else now = 1; } printf("%d ", now); } printf("\n"); continue; } int w = 0; for (int i = 2; i <= n; i++) { if (a[i] == a[i - 1]) { w = i; break; } } if (w) { printf("2\n1 "); int now = 1; for (int i = 2; i <= n; i++) { if (a[i] != a[i - 1]) { if (now == 1) now = 2; else now = 1; } if (i == w) { if (now == 1) now = 2; else now = 1; } printf("%d ", now); } printf("\n"); } else { printf("3\n3 1 "); int now = 1; for (int i = 3; i <= n; i++) { if (a[i] != a[i - 1]) { if (now == 1) now = 2; else now = 1; } printf("%d ", now); } printf("\n"); } } }