#include <bits/stdc++.h>
using namespace std;
int t, n, m, k, nn;
int a[500005], b[500005];
int sel_c(int x, int y) {
  if (k == 2) {
    k++;
    return k;
  }
  if (x + y == 3) return 3;
  if (x + y == 4) return 2;
  if (x + y == 5) return 1;
}
int sel_c1(int x) {
  if (k == 1) {
    k++;
    return k;
  }
  if (x == 1) return 2;
  if (x == 2) return 1;
  if (x == 3) return 2;
}
int f(int x, int y, int z) {
  if (b[x] != b[z]) {
    if (a[x] == a[y]) return b[x];
    if (a[z] == a[y]) return b[z];
    return sel_c(b[x], b[z]);
  }
  if (a[x] == a[y] && a[y] == a[z]) return b[x];
  return sel_c(b[x], b[z]);
}
int main(void) {
  int x = 0, y, z, xx = 0, p;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    for (int i = 0; i < (500005); i++) b[i] = 0;
    x = 0;
    for (int i = 0; i < (n); i++) {
      scanf("%d", &a[i]);
      if (i > 0 && a[i] != a[i - 1]) x++;
    }
    if (x == 0) {
      printf("%d\n", 1);
      for (int i = 0; i < (n); i++) printf("1 ");
      printf("\n");
      continue;
    }
    if (n % 2 == 0) {
      x = 0;
      printf("%d\n", 2);
      for (int i = 0; i < (n); i++) {
        printf("%d ", x + 1);
        x++;
        x %= 2;
      }
      printf("\n");
      continue;
    }
    y = 0;
    for (int i = (1); i <= (n - 1); i++) {
      if (a[i] == a[i - 1]) {
        y = i;
        break;
      }
    }
    if (y > 0) {
      x = 0;
      printf("%d\n", 2);
      for (int i = 0; i < (n); i++) {
        if (i == y)
          printf("%d ", x + 1);
        else {
          x++;
          x %= 2;
          printf("%d ", x + 1);
        }
      }
      printf("\n");
      continue;
    }
    if (y == 0 && a[0] == a[n - 1]) {
      x = 0;
      printf("%d\n", 2);
      for (int i = 0; i < (n - 1); i++) {
        printf("%d ", x + 1);
        x++;
        x %= 2;
      }
      printf("1\n");
      continue;
    }
    x = 0;
    printf("%d\n", 3);
    for (int i = 0; i < (n - 1); i++) {
      printf("%d ", x + 1);
      x++;
      x %= 2;
    }
    printf("3\n");
    continue;
  }
  return 0;
}
