#include <bits/stdc++.h>
using namespace std;
const int NN = 200100;
int a[NN];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    int all = 1;
    for (int i = 1; i <= n; i++) {
      scanf("%d", a + i);
      if (i > 1 && a[i] != a[i - 1]) all = 0;
    }
    if (all == 1) {
      printf("1\n");
      for (int i = 1; i <= n; i++) {
        printf("1 ");
      }
      printf("\n");
      continue;
    }
    a[n + 1] = a[1];
    if (n % 2 == 0) {
      printf("2\n");
      for (int i = 1; i <= n; i++) {
        printf("%d ", i % 2 + 1);
      }
      printf("\n");
    } else {
      if (a[1] == a[n]) {
        printf("2\n");
        for (int i = 1; i <= n; i++) {
          printf("%d ", i % 2 + 1);
        }
        printf("\n");
      } else {
        int can = 0, rec;
        for (int i = 1; i <= n; i++) {
          if (a[i] == a[i + 1]) {
            rec = i;
            can = 1;
            break;
          }
        }
        if (can == 0) {
          printf("3\n");
          for (int i = 1; i < n; i++) {
            printf("%d ", i % 2 + 1);
          }
          printf("3\n");
        } else {
          printf("2\n");
          int cur = 1;
          for (int i = 1; i <= n; i++) {
            if (i == rec) {
              printf("%d %d ", cur, cur);
              i++;
            } else {
              printf("%d ", cur);
            }
            cur = 3 - cur;
          }
          printf("\n");
        }
      }
    }
  }
  return 0;
}
