#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    int a[200000 + 7] = {0};
    int flag = 1;
    int is_same = 0;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      if (i && a[i] != a[i - 1]) flag = 0;
    }
    if (flag) {
      printf("1\n");
      for (int i = 0; i < n; ++i) {
        if (i) printf(" ");
        printf("1");
      }
      printf("\n");
    } else {
      if (n % 2 == 0) {
        printf("2\n");
        for (int i = 0; i < n; ++i) {
          if (i) printf(" ");
          printf("%d", i % 2 ? 2 : 1);
        }
        printf("\n");
      } else {
        int check = -1;
        for (int i = 0; i < n; ++i)
          if (a[(i + 1) % n] == a[i]) {
            check = i;
            break;
          }
        if (check == -1) {
          printf("3\n");
          for (int i = 0; i < n; i++) {
            if (i) printf(" ");
            if (i != n - 1)
              printf("%d", i % 2 ? 2 : 1);
            else
              printf("3");
          }
        } else {
          printf("2\n");
          for (int i = 0; i <= check; ++i) {
            if (i) printf(" ");
            printf("%d", i % 2 ? 2 : 1);
          }
          for (int i = check + 1; i < n; ++i) {
            if (i) printf(" ");
            printf("%d", i % 2 ? 1 : 2);
          }
        }
        printf("\n");
      }
    }
  }
  return 0;
}
