w=int(input(''))
q=input('')
qe=q[0]
qr=q[1]
qq=qe+qr
wq=q[3]
we=q[4]
ww=wq+we
if w==12:
    qq=int(qq)
    ww=int(ww)
    qe=int(qe)
    if qq==00:
        qr='1'

    if qq>12:
        if qe>0:
            qq='1'+qr
            qq=int(qq)
        if qq>12:
            qq='0'+qr
    else:
        qe=str(qe)
        qq=qe+qr

else:
    qq=int(qq)
    ww=int(ww)
    if qq>23:
        qq='0'+qr
    else:
        qq=qe+qr
if ww>=60:
    ww='0'+we
else:
    ww=wq+we
qq=str(qq)
print(qq+':'+ww)


w=int(input(''))
q=input('')
qe=q[0]
qw=q[1]
qq=qe+qw
wq=q[3]
we=q[4]
ww=wq+we
if w==12:
    qq=int(qq)
    ww=int(ww)
    if qq>12:
        qq='0'+qw
    else:
        qq=qe+qw

else:
    qq=int(qq)
    ww=int(ww)
    if qq>23:
        qq='0'+qw
    else:
        qq=qe+qw
if ww>60:
    ww='0'+we
else:
    ww=wq+we
print(qq+':'+ww)


w=int(input(''))
q=input('')
qe=q[0]
qr=q[1]
qq=qe+qr
wq=q[3]
we=q[4]
ww=wq+we
if w==12:
    qq=int(qq)
    ww=int(ww)
    if qq==00:
        qr='1'

    if qq>12:
        qq='0'+qr
    else:
        qq=qe+qr

else:
    qq=int(qq)
    ww=int(ww)
    if qq>23:
        qq='0'+qr
    else:
        qq=qe+qr
if ww>=60:
    ww='0'+we
else:
    ww=wq+we
print(qq+':'+ww)


w=int(input(''))
q=input('')
qe=q[0]
qr=q[1]
qq=qe+qr
wq=q[3]
we=q[4]
ww=wq+we
if w==12:
    qq=int(qq)
    ww=int(ww)
    qe=int(qe)
    if qq==00:
        qr='1'

    if qq>12:
        if qe>0:
            qq='1'+qr
        else:
            qq='0'+qr
    else:
        qq=qe+qr

else:
    qq=int(qq)
    ww=int(ww)
    if qq>23:
        qq='0'+qr
    else:
        qq=qe+qr
if ww>=60:
    ww='0'+we
else:
    ww=wq+we
qq=str(qq)
print(qq+':'+ww)


w=int(input(''))
q=input('')
qe=q[0]
qr=q[1]
qq=qe+qr
wq=q[3]
we=q[4]
ww=wq+we
if w==12:
    qq=int(qq)
    ww=int(ww)
    if qq==00:
        qr='1'

    if qq>12:
        qq='0'+qr
    else:
        qq=qe+qr

else:
    qq=int(qq)
    ww=int(ww)
    if qq>23:
        qq='0'+qr
    else:
        qq=qe+qr
if ww>60:
    ww='0'+we
else:
    ww=wq+we
print(qq+':'+ww)


w=int(input(''))
q=input('')
qe=q[0]
qr=q[1]
qq=qe+qr
wq=q[3]
we=q[4]
ww=wq+we
if w==12:
    qq=int(qq)
    ww=int(ww)
    if qq==00:
        qr='1'

    if qq>12:
        qq='0'+qr
    else:
        qq=qe+qr

else:
    qq=int(qq)
    ww=int(ww)
    if qq>23:
        qq='0'+qw
    else:
        qq=qe+qr
if ww>60:
    ww='0'+we
else:
    ww=wq+we
print(qq+':'+ww)


w=int(input(''))
q=input('')
qe=q[0]
qr=q[1]
qq=qe+qr
wq=q[3]
we=q[4]
ww=wq+we
if w==12:
    qq=int(qq)
    ww=int(ww)
    qe=int(qe)
    if qq==00:
        qr='1'

    if qq>12:
        if qe>0:
            qq='1'+qr
            qq=int(qq)
        if qq>12:
            qq='0'+qr
    else:
        qq=qe+qr

else:
    qq=int(qq)
    ww=int(ww)
    if qq>23:
        qq='0'+qr
    else:
        qq=qe+qr
if ww>=60:
    ww='0'+we
else:
    ww=wq+we
qq=str(qq)
print(qq+':'+ww)


#!/usr/bin/env python3

def main():
    try:
        while True:
            n = input()
            a, b = input().split(':')
            c, d = b
            a, b = a
            if c >= '6':
                c = '5'
            if n == "24":
                if a == '2':
                    if b >= '4':
                        b = '3'
                elif a >= '3':
                    a = '1'
            else:
                if a == b == '0':
                    b = '1'
                elif a == '1':
                    if b >= '3':
                        b = '2'
                elif a >= '2':
                    if b == '0':
                        a = '1'
                    else:
                        a = '0'

            print("%s%s:%s%s" % (a, b, c, d))

    except EOFError:
        pass

main()


using System;

class Fffuuuu {

    Boolean MG(String str) {
        return str.EndsWith("lios") || str.EndsWith("etr") || str.EndsWith("initis");
    }

    Boolean Pril(String str) {
        return str.EndsWith("lios") || str.EndsWith("liala");
    }

    Boolean Sush(String str) {
        return str.EndsWith("etr") || str.EndsWith("etra");
    }

    Boolean Glag(String str) {
        return str.EndsWith("initis") || str.EndsWith("inites");
    }

    Boolean Check(String text) {
        String[] tok = text.Split(new Char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        Boolean mg = MG(tok[0]);
        foreach (String s in tok) {
            if (MG(s) != mg) {
                return false;
            }
        }
        Int32 j = Array.FindIndex(tok, Sush);
        if (j < 0) {
            return false;
        }
        for (Int32 i = 0; i < j; ++i) {
            if (!Pril(tok[i])) {
                return false;
            }
        }
        for (Int32 i = j + 1; i < tok.Length; ++i) {
            if (!Glag(tok[i])) {
                return false;
            }
        }
        return true;
    }

    public Fffuuuu() {
        Console.WriteLine(Check(Console.ReadLine()) ? "YES" : "NO");
    }

    public static void Main() {
#if DEBUG
        Console.SetIn(new System.IO.StreamReader("in.txt"));
#endif
        new Fffuuuu();
    }

}


using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Ex3
{
    class Program
    {
        private const int LineCount = 1;

        static void Main(string[] args)
        {
            string[] ADJ = { "lios", "liala" };
            string[] NOUN = { "etr", "etra" };
            string[] VRB = { "initis", "inites" };

            //Console.In; //
            TextReader input = Console.In;//Environment.MachineName == "DANNY-TOSH" ? File.OpenText("Input.txt") : Console.In;
            string[] firstLines = new string[LineCount];
            for (int i = 0; i < LineCount; ++i)
                firstLines[i] = input.ReadLine();

            string[] words = firstLines[0].Split(' ');
            if (words.Length == 0)
            {
                Console.WriteLine("NO");
                return;
            }
            bool M;
            if (words[0].EndsWith(ADJ[0]) || words[0].EndsWith(NOUN[0]) || words[0].EndsWith(VRB[0]))
                M = true;
            else if (words[0].EndsWith(ADJ[1]) || words[0].EndsWith(NOUN[1]) || words[0].EndsWith(VRB[1]))
                M = false;
            else
            {
                Console.WriteLine("NO");
                return;
            }

            if (words.Length == 1)
            {
                Console.WriteLine("YES");
                return;
            }

            long currWord = 0;
            string currEnding = M ? ADJ[0] : ADJ[1];
            while (words.Length > currWord && words[currWord].EndsWith(currEnding)) currWord++;
            if (words.Length == currWord)
            {
                Console.WriteLine("NO");
                return;
            }

            currEnding = M ? NOUN[0] : NOUN[1];
            if (! words[currWord].EndsWith(currEnding))
            {
                Console.WriteLine("NO");
                return;
            }
            currWord++;
            currEnding = M ? VRB[0] : VRB[1];

            if (words.Length == currWord)
            {
                Console.WriteLine("YES");
                return;
            }

            while (words.Length > currWord && words[currWord].EndsWith(currEnding)) currWord++;
            if (words.Length == currWord)
            {
                Console.WriteLine("YES");
                return;
            }
            Console.WriteLine("NO");
        }
    }
}


using System;
using System.Collections.Generic;
#if (ONLINE_JUDGE != true)
using System.Diagnostics;
#endif
using System.Linq;

namespace A
{
    internal class Program
    {
        [Flags]
        private enum WordType : byte
        {
            Error = 0,

            Adjective = 1,
            Noun = 2,
            Adverb = 4,

            Male = 8,
            Female = 16
        }

        private static void Go()
        {
            var words = readStringList();

            var state = 0;
            WordType sex = WordType.Error;

            foreach (var word in words)
            {
                var wordInfo = CheckWord(word);
                var wordSex = (wordInfo & (WordType.Male | WordType.Female));

                if (sex == WordType.Error) sex = wordSex;
                if(wordSex != sex)
                {
                    Console.WriteLine("NO");
                    return;
                }

                if(state == 0)
                {
                    if((wordInfo & WordType.Adjective) != 0)
                        continue;
                    if ((wordInfo & WordType.Noun) != 0)
                    {
                        state = 1;
                        continue;
                    }
                }

                if(state == 1)
                {
                    if((wordInfo & WordType.Adverb) != 0)
                    {
                        state = 2;
                        continue;
                    }
                }

                if(state == 2)
                {
                    if((wordInfo & WordType.Adverb) != 0)
                        continue;
                }

                Console.WriteLine("NO");
                return;
            }

            if(state == 0)
                Console.WriteLine("NO");

            Console.WriteLine("YES");
        }

        private static WordType CheckWord(string word)
        {
            if(word.EndsWith("lios")) return WordType.Adjective | WordType.Male;
            if (word.EndsWith("liala")) return WordType.Adjective | WordType.Female;
            if (word.EndsWith("etr")) return WordType.Noun | WordType.Male;
            if (word.EndsWith("etra")) return WordType.Noun | WordType.Female;
            if (word.EndsWith("initis")) return WordType.Adverb | WordType.Male;
            if (word.EndsWith("inites")) return WordType.Adverb | WordType.Female;
            return WordType.Error;
        }

        #region Template

        private static void Main(string[] args)
        {
#if (ONLINE_JUDGE != true)
            var watch = new Stopwatch();
            watch.Start();
#endif
            Go();
#if (ONLINE_JUDGE != true)
            watch.Stop();
            DB("---------------------------------------");
            DB(watch.ElapsedMilliseconds);
            Console.ReadKey();
#endif
        }

        #region Readers

        private static int readInt()
        {
            return int.Parse(Console.ReadLine());
        }

        private static long readLong()
        {
            return long.Parse(Console.ReadLine());
        }

        private static float readFloat()
        {
            return float.Parse(Console.ReadLine());
        }

        private static char readChar()
        {
            return Console.ReadLine()[0];
        }

        private static string readString()
        {
            return Console.ReadLine();
        }

        private static IList<int> readIntList()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        }

        private static IList<long> readLongList()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToList();
        }

        private static IList<float> readFloatList()
        {
            return Console.ReadLine().Split(' ').Select(float.Parse).ToList();
        }

        private static IList<char> readCharList()
        {
            return Console.ReadLine().Split(' ').Select(x => x[0]).ToList();
        }

        private static IList<string> readStringList()
        {
            return Console.ReadLine().Split(' ').ToList();
        }

        private static int[] readIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        private static long[] readLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        private static float[] readFloatArray()
        {
            return Console.ReadLine().Split(' ').Select(float.Parse).ToArray();
        }

        private static char[] readCharArray()
        {
            return Console.ReadLine().Split(' ').Select(x=>x[0]).ToArray();
        }

        private static string[] readStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static int[,] readIntMatrix(long n, long m)
        {
            var result = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readIntArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }

        private static long[,] readLongMatrix(long n, long m)
        {
            var result = new long[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readLongArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }

        private static float[,] readFloatMatrix(long n, long m)
        {
            var result = new float[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readFloatArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }

        private static char[,] readCharMatrix(long n, long m)
        {
            var result = new char[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readCharArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }

        private static string[,] readStringMatrix(long n, long m)
        {
            var result = new string[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readStringArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }
        #endregion

        #region Writers

        private static void DB(string format, object[] args)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(format, args);
#endif
        }

        private static void DB(string value)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(value);
#endif
        }

        private static void DB(int value)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(value);
#endif
        }

        private static void DB(long value)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(value);
#endif
        }

        private static void DB(float value)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(value);
#endif
        }

        #endregion

        #endregion
    }
}


using System;
using System.Collections.Generic;
#if (ONLINE_JUDGE != true)
using System.Diagnostics;
#endif
using System.Linq;

namespace A
{
    internal class Program
    {
        [Flags]
        private enum WordType : byte
        {
            Error = 0,

            Adjective = 1,
            Noun = 2,
            Adverb = 4,

            Male = 8,
            Female = 16
        }

        private static object Go()
        {
            var words = readStringList();

            var state = 0;
            WordType sex = WordType.Error;

            foreach (var word in words)
            {
                var wordInfo = CheckWord(word);
                var wordSex = (wordInfo & (WordType.Male | WordType.Female));

                if (sex == WordType.Error) sex = wordSex;
                if(wordSex != sex)
                {
                    return "NO";
                }

                if(state == 0)
                {
                    if((wordInfo & WordType.Adjective) != 0)
                        continue;
                    if ((wordInfo & WordType.Noun) != 0)
                    {
                        state = 1;
                        continue;
                    }
                }

                if(state == 1)
                {
                    if((wordInfo & WordType.Adverb) != 0)
                        continue;
                }

                return "NO";
            }

            if (state == 0)
            {
                return "NO";
            }

            return "YES";
        }

        private static WordType CheckWord(string word)
        {
            if(word.EndsWith("lios")) return WordType.Adjective | WordType.Male;
            if (word.EndsWith("liala")) return WordType.Adjective | WordType.Female;
            if (word.EndsWith("etr")) return WordType.Noun | WordType.Male;
            if (word.EndsWith("etra")) return WordType.Noun | WordType.Female;
            if (word.EndsWith("initis")) return WordType.Adverb | WordType.Male;
            if (word.EndsWith("inites")) return WordType.Adverb | WordType.Female;
            return WordType.Error;
        }

        #region Template

        private static void Main(string[] args)
        {
#if (ONLINE_JUDGE != true)
            var watch = new Stopwatch();
            watch.Start();
#endif
            var result = Go();
            if (result != null)
                Console.WriteLine(result);
#if (ONLINE_JUDGE != true)
            watch.Stop();
            DB("---------------------------------------");
            DB(watch.ElapsedMilliseconds);
            Console.ReadKey();
#endif
        }

        #region Readers

        private static int readInt()
        {
            return int.Parse(Console.ReadLine());
        }

        private static long readLong()
        {
            return long.Parse(Console.ReadLine());
        }

        private static float readFloat()
        {
            return float.Parse(Console.ReadLine());
        }

        private static char readChar()
        {
            return Console.ReadLine()[0];
        }

        private static string readString()
        {
            return Console.ReadLine();
        }

        private static IList<int> readIntList()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        }

        private static IList<long> readLongList()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToList();
        }

        private static IList<float> readFloatList()
        {
            return Console.ReadLine().Split(' ').Select(float.Parse).ToList();
        }

        private static IList<char> readCharList()
        {
            return Console.ReadLine().Split(' ').Select(x => x[0]).ToList();
        }

        private static IList<string> readStringList()
        {
            return Console.ReadLine().Split(' ').ToList();
        }

        private static int[] readIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        private static long[] readLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        private static float[] readFloatArray()
        {
            return Console.ReadLine().Split(' ').Select(float.Parse).ToArray();
        }

        private static char[] readCharArray()
        {
            return Console.ReadLine().Split(' ').Select(x=>x[0]).ToArray();
        }

        private static string[] readStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static int[,] readIntMatrix(long n, long m)
        {
            var result = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readIntArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }

        private static long[,] readLongMatrix(long n, long m)
        {
            var result = new long[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readLongArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }

        private static float[,] readFloatMatrix(long n, long m)
        {
            var result = new float[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readFloatArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }

        private static char[,] readCharMatrix(long n, long m)
        {
            var result = new char[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readCharArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }

        private static string[,] readStringMatrix(long n, long m)
        {
            var result = new string[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readStringArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }
        #endregion

        #region Writers

        private static void DB(string format, object[] args)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(format, args);
#endif
        }

        private static void DB(string value)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(value);
#endif
        }

        private static void DB(int value)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(value);
#endif
        }

        private static void DB(long value)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(value);
#endif
        }

        private static void DB(float value)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(value);
#endif
        }

        #endregion

        #endregion
    }
}


using System;
using System.Collections.Generic;
#if (ONLINE_JUDGE != true)
using System.Diagnostics;
#endif
using System.Linq;

namespace A
{
    internal class Program
    {
        [Flags]
        private enum WordType : byte
        {
            Error = 0,

            Adjective = 1,
            Noun = 2,
            Adverb = 4,

            Male = 8,
            Female = 16
        }

        private static void Go()
        {
            var words = readStringList();

            var state = 0;
            WordType sex = WordType.Error;

            foreach (var word in words)
            {
                var wordInfo = CheckWord(word);
                var wordSex = (wordInfo & (WordType.Male | WordType.Female));

                if (sex == WordType.Error) sex = wordSex;
                if(wordSex != sex)
                {
                    Console.WriteLine("NO");
                    return;
                }

                if(state == 0)
                {
                    if((wordInfo & WordType.Adjective) != 0)
                        continue;
                    if ((wordInfo & WordType.Noun) != 0)
                    {
                        state = 1;
                        continue;
                    }
                }

                if(state == 1)
                {
                    if((wordInfo & WordType.Adverb) != 0)
                    {
                        state = 2;
                        continue;
                    }
                }

                if(state == 2)
                {
                    if((wordInfo & WordType.Adverb) != 0)
                        continue;
                }

                Console.WriteLine("NO");
                return;
            }

            if(state != 2)
                Console.WriteLine("NO");

            Console.WriteLine("YES");
        }

        private static WordType CheckWord(string word)
        {
            if(word.EndsWith("lios")) return WordType.Adjective | WordType.Male;
            if (word.EndsWith("liala")) return WordType.Adjective | WordType.Female;
            if (word.EndsWith("etr")) return WordType.Noun | WordType.Male;
            if (word.EndsWith("etra")) return WordType.Noun | WordType.Female;
            if (word.EndsWith("initis")) return WordType.Adverb | WordType.Male;
            if (word.EndsWith("inites")) return WordType.Adverb | WordType.Female;
            return WordType.Error;
        }

        #region Template

        private static void Main(string[] args)
        {
#if (ONLINE_JUDGE != true)
            var watch = new Stopwatch();
            watch.Start();
#endif
            Go();
#if (ONLINE_JUDGE != true)
            watch.Stop();
            DB("---------------------------------------");
            DB(watch.ElapsedMilliseconds);
            Console.ReadKey();
#endif
        }

        #region Readers

        private static int readInt()
        {
            return int.Parse(Console.ReadLine());
        }

        private static long readLong()
        {
            return long.Parse(Console.ReadLine());
        }

        private static float readFloat()
        {
            return float.Parse(Console.ReadLine());
        }

        private static char readChar()
        {
            return Console.ReadLine()[0];
        }

        private static string readString()
        {
            return Console.ReadLine();
        }

        private static IList<int> readIntList()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        }

        private static IList<long> readLongList()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToList();
        }

        private static IList<float> readFloatList()
        {
            return Console.ReadLine().Split(' ').Select(float.Parse).ToList();
        }

        private static IList<char> readCharList()
        {
            return Console.ReadLine().Split(' ').Select(x => x[0]).ToList();
        }

        private static IList<string> readStringList()
        {
            return Console.ReadLine().Split(' ').ToList();
        }

        private static int[] readIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        private static long[] readLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        private static float[] readFloatArray()
        {
            return Console.ReadLine().Split(' ').Select(float.Parse).ToArray();
        }

        private static char[] readCharArray()
        {
            return Console.ReadLine().Split(' ').Select(x=>x[0]).ToArray();
        }

        private static string[] readStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static int[,] readIntMatrix(long n, long m)
        {
            var result = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readIntArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }

        private static long[,] readLongMatrix(long n, long m)
        {
            var result = new long[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readLongArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }

        private static float[,] readFloatMatrix(long n, long m)
        {
            var result = new float[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readFloatArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }

        private static char[,] readCharMatrix(long n, long m)
        {
            var result = new char[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readCharArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }

        private static string[,] readStringMatrix(long n, long m)
        {
            var result = new string[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readStringArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }
        #endregion

        #region Writers

        private static void DB(string format, object[] args)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(format, args);
#endif
        }

        private static void DB(string value)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(value);
#endif
        }

        private static void DB(int value)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(value);
#endif
        }

        private static void DB(long value)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(value);
#endif
        }

        private static void DB(float value)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(value);
#endif
        }

        #endregion

        #endregion
    }
}


using System;
using System.Collections.Generic;
#if (ONLINE_JUDGE != true)
using System.Diagnostics;
#endif
using System.Linq;

namespace A
{
    internal class Program
    {
        [Flags]
        private enum WordType : byte
        {
            Error = 0,

            Adjective = 1,
            Noun = 2,
            Adverb = 4,

            Male = 8,
            Female = 16
        }

        private static object Go()
        {
            var words = readStringList();

            var state = 0;
            WordType sex = WordType.Error;

            if (words.Count == 1 && CheckWord(words[0]) != WordType.Error)
                return "YES";

            foreach (var word in words)
            {
                var wordInfo = CheckWord(word);
                var wordSex = (wordInfo & (WordType.Male | WordType.Female));

                if (sex == WordType.Error) sex = wordSex;
                if(wordSex != sex)
                {
                    return "NO";
                }

                if(state == 0)
                {
                    if((wordInfo & WordType.Adjective) != 0)
                        continue;
                    if ((wordInfo & WordType.Noun) != 0)
                    {
                        state = 1;
                        continue;
                    }
                }

                if(state == 1)
                {
                    if((wordInfo & WordType.Adverb) != 0)
                        continue;
                }

                return "NO";
            }

            if (state == 0)
            {
                return "NO";
            }

            return "YES";
        }

        private static WordType CheckWord(string word)
        {
            if(word.EndsWith("lios")) return WordType.Adjective | WordType.Male;
            if (word.EndsWith("liala")) return WordType.Adjective | WordType.Female;
            if (word.EndsWith("etr")) return WordType.Noun | WordType.Male;
            if (word.EndsWith("etra")) return WordType.Noun | WordType.Female;
            if (word.EndsWith("initis")) return WordType.Adverb | WordType.Male;
            if (word.EndsWith("inites")) return WordType.Adverb | WordType.Female;
            return WordType.Error;
        }

        #region Template

        private static void Main(string[] args)
        {
#if (ONLINE_JUDGE != true)
            var watch = new Stopwatch();
            watch.Start();
#endif
            var result = Go();
            if (result != null)
                Console.WriteLine(result);
#if (ONLINE_JUDGE != true)
            watch.Stop();
            DB("---------------------------------------");
            DB(watch.ElapsedMilliseconds);
            Console.ReadKey();
#endif
        }

        #region Readers

        private static int readInt()
        {
            return int.Parse(Console.ReadLine());
        }

        private static long readLong()
        {
            return long.Parse(Console.ReadLine());
        }

        private static float readFloat()
        {
            return float.Parse(Console.ReadLine());
        }

        private static char readChar()
        {
            return Console.ReadLine()[0];
        }

        private static string readString()
        {
            return Console.ReadLine();
        }

        private static IList<int> readIntList()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        }

        private static IList<long> readLongList()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToList();
        }

        private static IList<float> readFloatList()
        {
            return Console.ReadLine().Split(' ').Select(float.Parse).ToList();
        }

        private static IList<char> readCharList()
        {
            return Console.ReadLine().Split(' ').Select(x => x[0]).ToList();
        }

        private static IList<string> readStringList()
        {
            return Console.ReadLine().Split(' ').ToList();
        }

        private static int[] readIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        private static long[] readLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        private static float[] readFloatArray()
        {
            return Console.ReadLine().Split(' ').Select(float.Parse).ToArray();
        }

        private static char[] readCharArray()
        {
            return Console.ReadLine().Split(' ').Select(x=>x[0]).ToArray();
        }

        private static string[] readStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static int[,] readIntMatrix(long n, long m)
        {
            var result = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readIntArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }

        private static long[,] readLongMatrix(long n, long m)
        {
            var result = new long[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readLongArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }

        private static float[,] readFloatMatrix(long n, long m)
        {
            var result = new float[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readFloatArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }

        private static char[,] readCharMatrix(long n, long m)
        {
            var result = new char[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readCharArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }

        private static string[,] readStringMatrix(long n, long m)
        {
            var result = new string[n, m];
            for (int i = 0; i < n; i++)
            {
                var row = readStringArray();
                for (int j = 0; j < m; j++)
                {
                    result[i, j] = row[i];
                }
            }

            return result;
        }
        #endregion

        #region Writers

        private static void DB(string format, object[] args)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(format, args);
#endif
        }

        private static void DB(string value)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(value);
#endif
        }

        private static void DB(int value)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(value);
#endif
        }

        private static void DB(long value)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(value);
#endif
        }

        private static void DB(float value)
        {
#if (ONLINE_JUDGE != true)
            Console.WriteLine(value);
#endif
        }

        #endregion

        #endregion
    }
}


<?
$hz=trim(fgets(STDIN))." ";
if (  preg_match('/^(\w*liala )*(\w*etra )(\w*inites )*$/',$hz)
|| preg_match('/^(\w*lios )*(\w*etr )(\w*initis )*$/',$hz)
|| preg_match('/^\w*(lios|liala|etr|etra|initis|inites) $/',$hz)
) echo "YES"; else echo "NO";
?>


import re

pats = [r'^(\w*lios )*(\w*etr)( \w*initis)$',
		r'^(\w*liala )*(\w*etra)( \w*inites)$',
		r'^\w*(lios|liala|etr|etra|initis|inites)']

ans = False
for pat in pats:
	if re.match(pat, raw_input()):
		ans = True

print "YES" if ans else "NO"


import re

pats = [r'^(\w*lios )*(\w*etr)( \w*initis)*$',
		r'^(\w*liala )*(\w*etra)( \w*inites)*$',
		r'^\w*(lios|liala|etr|etra|initis|inites)$']

ans = False
s = raw_input().strip()
for pat in pats:
	if re.match(pat, s):
		ans = True

print "YES" if ans else "NO"


import re

pats = [r'^(\w*lios )*(\w*etr)( \w*initis)$',
		r'^(\w*liala )*(\w*etra)( \w*inites)$',
		r'^\w*(lios|liala|etr|etra|initis|inites)$']

ans = False
s = raw_input().strip()
for pat in pats:
	if re.match(pat, s):
		ans = True

print "YES" if ans else "NO"


def same(w1, w2):
	return isMale(w1) == isMale(w2)

def isMale(word):
	if word.endswith("lios") or word.endswith("etr") or word.endswith("initis"):
		return True
	return False
def isAdj(word):
	return word.endswith("lios") or word.endswith("liala")
def isNoun(word):
	return word.endswith("etr") or word.endswith("etra")
def isVerb(word):
	return word.endswith("initis") or word.endswith("inites")

words = raw_input().split()

ans = True

allowAdj = True
allowNoun = True
allowVerb = False
for i in range(len(words)):
	if i > 0 and not same(words[i - 1], words[i]):
		ans = False
		break
	if isAdj(words[i]) and allowAdj:
		pass
	elif isNoun(words[i]) and allowNoun:
		allowAdj, allowNoun, allowVerb = False, False, True
	elif isVerb(words[i]) and allowVerb:
		pass
	else:
		ans = False
		break
ans = ans and not allowNoun

if len(words) == 1:
	ans = isAdj(words[0]) or isNoun(words[0]) or isVerb(words[0])

print "YES" if ans else "NO"


import re

pats = [r'^(\w*lios )*(\w*etr)( \w*initis)$',
		r'^(\w*liala )*(\w*etra)( \w*inites)$',
		r'^\w*(lios|liala|etr|etra|initis|inites)']

ans = False
s = raw_input()
for pat in pats:
	if re.match(pat, s):
		ans = True

print "YES" if ans else "NO"


def same(w1, w2):
	return isMale(w1) == isMale(w2)

def isMale(word):
	if word.endswith("lios") or word.endswith("etr") or word.endswith("initis"):
		return True
	return False
def isAdj(word):
	return word.endswith("lios") or word.endswith("liala")
def isNoun(word):
	return word.endswith("etr") or word.endswith("etra")
def isVerb(word):
	return word.endswith("initis") or word.endswith("inites")

words = raw_input().split()

ans = True

allowAdj = True
allowNoun = True
allowVerb = False
for i in range(len(words)):
	if i > 0 and not same(words[i - 1], words[i]):
		ans = False
		break
	if isAdj(words[i]) and allowAdj:
		pass
	elif isNoun(words[i]) and allowNoun:
		allowAdj, allowNoun, allowVerb = False, False, True
	elif isVerb(words[i]) and allowVerb:
		pass
	else:
		ans = False
		break

if len(words) == 1:
	ans = isAdj(words[0]) or isNoun(words[0]) or isVerb(words[0])

print "YES" if ans else "NO"


def same(w1, w2):
	return isMale(w1) == isMale(w2)

def isMale(word):
	if word.endswith("lios") or word.endswith("etr") or word.endswith("initis"):
		return True
	return False
def isAdj(word):
	return word.endswith("lios") or word.endswith("liala")
def isNoun(word):
	return word.endswith("etr") or word.endswith("etra")
def isVerb(word):
	return word.endswith("initis") or word.endswith("inites")

words = raw_input().split()

ans = True

allowAdj = True
allowNoun = True
allowVerb = False
for i in range(len(words)):
	if i > 0 and not same(words[i - 1], words[i]):
		ans = False
		break
	if isAdj(words[i]) and allowAdj:
		pass
	elif isNoun(words[i]) and allowNoun:
		allowAdj, allowNoun, allowVerb = False, False, True
	elif isVerb(words[i]) and allowVerb:
		pass
	else:
		ans = False
		break
ans = ans and not allowNoun

print "YES" if ans else "NO"


import re

pats = [r'^(\w*lios )*(\w*etr)( \w*initis)$',
		r'^(\w*liala )*(\w*etra)( \w*inites)$',
		r'^\w*(lios|liala|etr|etra|initis|inites)$']

ans = False
s = raw_input()
for pat in pats:
	if re.match(pat, s):
		ans = True

print "YES" if ans else "NO"


def same(w1, w2):
	return isMale(w1) == isMale(w2)

def isMale(word):
	if word.endswith("lios") or word.endswith("etr") or word.endswith("initis"):
		return True
	return False
def isAdj(word):
	return word.endswith("lios") or word.endswith("liala")
def isNoun(word):
	return word.endswith("etr") or word.endswith("etra")
def isVerb(word):
	return word.endswith("initis") or word.endswith("inites")

words = raw_input().split()

ans = True

allowAdj = True
allowNoun = True
allowVerb = False
for i in range(len(words)):
	if i > 0 and not same(words[i - 1], words[i]):
		ans = False
		break
	if isAdj(words[i]) and allowAdj:
		pass
	elif isNoun(words[i]) and allowNoun:
		allowAdj, allowNoun, allowVerb = False, False, True
	elif isVerb(words[i]) and allowVerb:
		pass
	else:
		ans = False
		break

print "YES" if ans else "NO"


# finding the various cases took the most time
def ch_gen(word):
    for x in gen:
        for w in range(3):
            try:
                if word[-len(gen[x][w]):] == gen[x][w]: return (x,str(w))
            except IndexError: continue
    return (-1,-1)
gen = {0:['lios','etr','initis'],1:['liala','etra','inites']}
s = input().split()
if len(s) == 1: print("YES" if ch_gen(s[0])[0] != -1 else "NO")
else:
    gender = ch_gen(s[0]); arr = [0]*len(s);
    arr[0] = gender[1]; flag = True
    for t in range(1,len(s)):
        nxt = ch_gen(s[t]); arr[t] = nxt[1]
        if nxt[0]!=gender[0] or gender[0] == -1: print('NO'); exit()
    act = "".join(arr);
    tur,fur,cur,sir,nut= act.count('1'),act.count('02'),act.count('20'),act.count('21'),act.count('10')
    if tur == 0 or tur > 1 or fur or cur or sir or nut: flag = False
    print("YES" if flag else "NO")


words = [c for c in input().split()]
verdict = True
category = ["" for i in range(len(words))]
for i  in range(len(words)):
	if (not verdict): break
	if (len(words[i]) < 3): verdict = False
	elif (words[i][-3:] == "etr" or (len(words[i]) >= 4 and words[i][-4:] == "etra")): category[i] = "noun"
	elif ((len(words[i]) >= 4 and words[i][-4:] == "lios") or (len(words[i]) >= 5 and words[i][-5:] == "liala")): category[i] = "adjective"
	elif (len(words[i]) >= 6 and (words[i][-6:] == "initis" or words[i][-6:] == "inites")): category[i] = "verb"
	else: verdict = False

first_noun = -1
for i in range(len(category)):
	if (not verdict): break
	if (category[i] == "noun"):
		first_noun = i
		break

if (first_noun == -1 and len(words) > 1): verdict = False
elif (first_noun != -1 and verdict):
	left, right = first_noun - 1, first_noun + 1
	while (left >= 0 and category[left] == "adjective"): left -= 1
	while (right < len(category) and category[right] == "verb"): right += 1

	if (left >= 0 or right < len(category)): verdict = False

print(("NO" if (not verdict) else "YES"))


words = [c for c in input().split()]
verdict = True
category = ["" for i in range(len(words))]
gender = ["" for i in range(len(words))]
for i  in range(len(words)):
	if (not verdict): break
	if (len(words[i]) < 3): verdict = False
	elif (words[i][-3:] == "etr"):
		category[i] = "noun"
		gender[i] = "male"
	elif (len(words[i]) >= 4 and words[i][-4:] == "etra"):
		category[i] = "noun"
		gender[i] = "female"
	elif ((len(words[i]) >= 4 and words[i][-4:] == "lios")):
		category[i] = "adjective"
		gender[i] = "male"
	elif (len(words[i]) >= 5 and words[i][-5:] == "liala"):
		category[i] = "adjective"
		gender[i] = "female"
	elif (len(words[i]) >= 6):
		category[i] = "verb"
		if (words[i][-6:] == "initis"): gender[i] = "male"
		elif (words[i][-6:] == "inites"): gender[i] = "female"
		else: verdict = False
	else: verdict = False

first_noun = -1
for i in range(len(category)):
	if (not verdict): break
	if (category[i] == "noun"):
		first_noun = i
		break

if (first_noun == -1 and len(words) > 1): verdict = False
elif (first_noun != -1 and verdict):
	left, right = first_noun - 1, first_noun + 1
	while (left >= 0 and category[left] == "adjective" and gender[left] == gender[first_noun]): left -= 1
	while (right < len(category) and category[right] == "verb" and gender[right] == gender[first_noun]): right += 1

	if (left >= 0 or right < len(category)): verdict = False

print(("NO" if (not verdict) else "YES"))


words = [c for c in input().split()]
verdict = True
category = ["" for i in range(len(words))]
for i  in range(len(words)):
	if (not verdict): break
	if (len(words[i]) < 3): verdict = False
	elif (words[i][-3:] == "etr" or (len(words[i]) >= 4 and words[i][-4:] == "etra")): category[i] = "noun"
	elif ((len(words[i]) >= 4 and words[i][-4:] == "lios") or (len(words[i]) >= 5 and words[i][-5:] == "liala")): category[i] = "adjective"
	elif (len(words[i]) >= 6 and (words[i][-6:] == "initis" or words[i][-6:] == "inites")): category[i] = "verb"
	else: verdict = False

first_noun = -1
for i in range(len(category)):
	if (category[i] == "noun"):
		first_noun = i
		break

if (first_noun == -1 and len(words) > 1): verdict = False
elif (first_noun != -1):
	left, right = first_noun - 1, first_noun + 1
	while (left >= 0 and category[left] != "noun"): left -= 1
	while (right < len(category) and category[right] != "noun"): right += 1

	if (left >= 0 or right < len(category)): verdict = False

print(("NO" if (not verdict) else "YES"))


words = [c for c in input().split()]
verdict = True
category = ["" for i in range(len(words))]
for i  in range(len(words)):
	if (not verdict): break
	if (len(words[i]) < 3): verdict = False
	elif (words[i][-3:] == "etr" or (len(words[i]) >= 4 and words[i][-4:] == "etra")): category[i] = "noun"
	elif ((len(words[i]) >= 4 and words[i][-4:] == "lios") or (len(words[i]) >= 5 and words[i][-5:] == "liala")): category[i] = "adjective"
	elif (len(words[i]) >= 6 and (words[i][-6:] == "initis" or words[i][-6:] == "inites")): category[i] = "verb"
	else: verdict = False

first_noun = -1
for i in range(len(category)):
	if (not verdict): break
	if (category[i] == "noun"):
		first_noun = i
		break

if (first_noun == -1 and len(words) > 1): verdict = False
elif (first_noun != -1 and verdict):
	left, right = first_noun - 1, first_noun + 1
	while (left >= 0 and category[left] == "adjective"): left -= 1
	while (right < len(category) and category[right] != "verb"): right += 1

	if (left >= 0 or right < len(category)): verdict = False

print(("NO" if (not verdict) else "YES"))


words = [c for c in input().split()]
verdict = True
category = ["" for i in range(len(words))]
for i  in range(len(words)):
	if (not verdict): break
	if (len(words[i]) < 3): verdict = False
	elif (words[i][-3:] == "etr" or (len(words[i]) >= 4 and words[i][-4:] == "etra")): category[i] = "noun"
	elif ((len(words[i]) >= 4 and words[i][-4:] == "lios") or (len(words[i]) >= 5 and words[i][-5:] == "liala")): category[i] = "adjective"
	elif (len(words[i]) >= 6 and (words[i][-6:] == "initis" or words[i][-6:] == "inites")): category[i] = "verb"
	else: verdict = False

first_noun = -1
for i in range(len(category)):
	if (category[i] == "noun"):
		first_noun = i
		break

if (first_noun == -1): verdict = False
else:
	left, right = first_noun - 1, first_noun + 1
	while (left >= 0 and category[left] != "noun"): left -= 1
	while (right < len(category) and category[right] != "noun"): right += 1

	if (left >= 0 or right < len(category)): verdict = False

print(("NO" if (not verdict) else "YES"))


#include<bits/stdc++.h>

using namespace std ;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define pb push_back
#define pf push_front
#define mp make_pair

void start()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin);
        freopen("output.txt" , "w" , stdout);
    #endif
}

int main(){
	fastio
	start() ;
	int t ;
	cin >> t ;
	while(t--){
		int n ;
		cin >> n ;
		int* a = new int[n] ;
		for(int i = 0 ; i < n ; i++){
			cin >> a[i] ;
		}
			vector<int> v;
			int start = 1 ;
			vector< pair<int,int> > vec;
			for(int i = 0 ; i < n ; i++){
					int flag = 0 ;
					for(int j = 0 ; j < vec.size() ; j++){
						if((a[i]%vec[j].first)==0){
							v.push_back(vec[j].second) ;
							flag = 1 ;
							break ;
						}
					}
					if(!flag){
						for(int j = 2 ; j <= a[i] ; j++){
								if(a[i]%j==0){
									vec.pb(make_pair(j,start)) ;
								}
						}
							v.pb(start) ;
							start++ ;
					}

			}
			int max1 = INT_MIN ;
			for(int i = 0 ; i < v.size() ; i++){
				max1 = max(v[i],max1) ;
			}
			cout << max1 << endl;
			for(int i = 0 ; i < v.size(); i++){
				cout << v[i] << " " ;
			}
			cout << endl ;

	}

	return 0 ;
}


#include<bits/stdc++.h>

using namespace std ;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define pb push_back
#define pf push_front
#define mp make_pair

void start()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin);
        freopen("output.txt" , "w" , stdout);
    #endif
}

// int n = 10e8;
// int* dp = new int[n] ;

// void sieve(){

// 	for(int i = 0 ; i < n ; i++){
// 		dp[i] = 1 ;
// 	}
// 	dp[0] = 0 ;
// 	dp[1] = 0 ;
// 	for(int i  = 2 ; i*i <= n ; i++){
// 		if(dp[i]){
// 			for(int j = i*i ; j<=n ; j+=i){
// 				dp[j] = 0 ;
// 			}
// 		}
// 	}
// }

int main(){
	fastio
	start() ;
	// sieve() ;
	int t ;
	cin >> t ;
	while(t--){
		int n ;
		cin >> n ;
		int* a = new int[n] ;
		for(int i = 0 ; i < n ; i++){
			cin >> a[i] ;
		}
		int diff = 0 , even = 0;
		if(n<=11){
			cout << n << endl ;
			for(int i = 1 ; i <= n ; i++){
				cout << i << " " ;
			}
			cout << endl ;
			// continue ;
		}
		else{
			vector<int> v;
			int start = 1 ;
			vector< pair<int,int> > vec;
			for(int i = 0 ; i < n ; i++){
				if(a[i]==1){
					v.pb(start) ;
					start++;
					continue ;
				}
				// else if(dp[a[i]] && a[i]&1){
				// 	v.pb(start) ;
				// 	start++;
				// }
				else{
					int flag = 0 ;
					for(int j = 0 ; j < vec.size() ; j++){
						if((a[i]%vec[j].first)==0){
							// cout << "dfhvk" << endl ;
							// cout << a[i] << " " << j << endl ;
							v.push_back(vec[j].second) ;
							flag = 1 ;
							break ;
						}
					}
					int temp = 0 ;
					if(!flag){
						// diff++;
						for(int j = 2 ; j*j <= a[i] ; j++){
								if(a[i]%j==0){
									// cout << "dbfvirf" << endl ;
									// cout << a[i] << " " << j << endl ;
									vec.pb(make_pair(j,start)) ;
									temp = 1 ;
							    }
						}
						if(!temp){
							vec.pb(mp(a[i],start)) ;
							v.pb(start) ;
							start++;
						}
						else{
							v.pb(start) ;
							start++ ;
							temp = 0 ;
						}
					}

				}
			}
			int max1 = INT_MIN ;
			for(int i = 0 ; i < v.size() ; i++){
				max1 = max(v[i],max1) ;
			}
			cout << max1 << endl;
			for(int i = 0 ; i < v.size(); i++){
				cout << v[i] << " " ;
			}
			cout << endl ;
		}

	}

	return 0 ;
}


#include<bits/stdc++.h>

using namespace std ;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define pb push_back
#define pf push_front
#define mp make_pair

void start()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin);
        freopen("output.txt" , "w" , stdout);
    #endif
}

int main(){
	fastio
	start() ;
	int t ;
	cin >> t ;
	while(t--){
		int n ;
		cin >> n ;
		int* a = new int[n] ;
		for(int i = 0 ; i < n ; i++){
			cin >> a[i] ;
		}
			vector<int> v;
			int start = 1 ;
			vector< pair<int,int> > vec;
			for(int i = 0 ; i < n ; i++){
					int flag = 0 ;
					for(int j = 0 ; j < vec.size() ; j++){
						if((a[i]%vec[j].first)==0){
							v.push_back(vec[j].second) ;
							flag = 1 ;
							break ;
						}
					}
					int temp = 0 ;
					if(!flag){
						for(int j = 2 ; j*j <= a[i] ; j++){
								if(a[i]%j==0){
									vec.pb(make_pair(j,start)) ;
									temp = 1 ;
								}
						}
						if(!temp){
							vec.pb(mp(a[i],start)) ;
							v.pb(start) ;
							start++;
						}
						else{
							v.pb(start) ;
							start++ ;
							temp = 0 ;
						}
					}

			}
			int max1 = INT_MIN ;
			for(int i = 0 ; i < v.size() ; i++){
				max1 = max(v[i],max1) ;
			}
			cout << max1 << endl;
			for(int i = 0 ; i < v.size(); i++){
				cout << v[i] << " " ;
			}
			cout << endl ;

	}

	return 0 ;
}


#include<bits/stdc++.h>

using namespace std ;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define pb push_back
#define pf push_front
#define mp make_pair

void start()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin);
        freopen("output.txt" , "w" , stdout);
    #endif
}

int main(){
	fastio
	start() ;
	int t ;
	cin >> t ;
	while(t--){
		int n ;
		cin >> n ;
		int* a = new int[n] ;
		for(int i = 0 ;i < n; i++){
			cin >> a[i] ;
		}
		int arr[] = {2,3,5,7,11,13,17,19,23,29,31} ;
		int brr[] = {1,2,3,4,5,6,7,8,9,10,11} ;
		int* count = new int[11]() ;
		for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < 11 ;j++){
				if(a[i]%arr[j]==0){
					a[i]=brr[j] ;
					break ;
				}
			}
		}
		int* max = max_element(a,a+n) ;
		cout << *max << endl ;
		for(int i = 0 ; i < n  ;i++){
			cout << a[i] << " " ;
		}
		cout << endl ;
	}

	return 0 ;
}


#include<bits/stdc++.h>

using namespace std ;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define pb push_back
#define pf push_front
#define mp make_pair

void start()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin);
        freopen("output.txt" , "w" , stdout);
    #endif
}

// int n = 10e8;
// int* dp = new int[n] ;

// void sieve(){

// 	for(int i = 0 ; i < n ; i++){
// 		dp[i] = 1 ;
// 	}
// 	dp[0] = 0 ;
// 	dp[1] = 0 ;
// 	for(int i  = 2 ; i*i <= n ; i++){
// 		if(dp[i]){
// 			for(int j = i*i ; j<=n ; j+=i){
// 				dp[j] = 0 ;
// 			}
// 		}
// 	}
// }

int main(){
	fastio
	start() ;
	// sieve() ;
	int t ;
	cin >> t ;
	while(t--){
		int n ;
		cin >> n ;
		int* a = new int[n] ;
		for(int i = 0 ; i < n ; i++){
			cin >> a[i] ;
		}
		int diff = 0 , even = 0;
		if(n<=11){
			cout << n << endl ;
			for(int i = 1 ; i <= n ; i++){
				cout << i << " " ;
			}
			cout << endl ;
			// continue ;
		}
		else{
			vector<int> v;
			int start = 1 ;
			vector< pair<int,int> > vec;
			for(int i = 0 ; i < n ; i++){
				if(a[i]==1){
					v.pb(start) ;
					start++;
					continue ;
				}
				// else if(dp[a[i]] && a[i]&1){
				// 	v.pb(start) ;
				// 	start++;
				// }
				else{
					int flag = 0 ;
					for(int j = 0 ; j < vec.size() ; j++){
						if((a[i]%vec[j].first)==0){
							// cout << "dfhvk" << endl ;
							// cout << a[i] << " " << j << endl ;
							v.push_back(vec[j].second) ;
							flag = 1 ;
							break ;
						}
					}
					int temp = 0 ;
					if(!flag){
						// diff++;
						for(int j = 3 ; j*j <= a[i] ; j++){
								if(a[i]%j==0){
									// cout << "dbfvirf" << endl ;
									// cout << a[i] << " " << j << endl ;
									vec.pb(make_pair(j,start)) ;
									temp = 1 ;
							    }
						}
						if(!temp){
							vec.pb(mp(a[i],start)) ;
							v.pb(start) ;
							start++;
						}
						else{
							v.pb(start) ;
							start++ ;
							temp = 0 ;
						}
					}

				}
			}
			int * x = new int[11]() ;
			for(int i = 0 ; i < v.size() ; i++){
				x[v[i]-1]++ ;
			}
			for(int i = 0 ; i < 11 ; i++){
				if(x[i]){
					diff++ ;
				}
			}
			cout << diff << endl ;
			for(int i = 0 ; i < v.size(); i++){
				cout << v[i] << " " ;
			}
			cout << endl ;
		}

	}

	return 0 ;
}


#include<bits/stdc++.h>

using namespace std ;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define pb push_back
#define pf push_front
#define mp make_pair

void start()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin);
        freopen("output.txt" , "w" , stdout);
    #endif
}

// int n = 10e8;
// int* dp = new int[n] ;

// void sieve(){

// 	for(int i = 0 ; i < n ; i++){
// 		dp[i] = 1 ;
// 	}
// 	dp[0] = 0 ;
// 	dp[1] = 0 ;
// 	for(int i  = 2 ; i*i <= n ; i++){
// 		if(dp[i]){
// 			for(int j = i*i ; j<=n ; j+=i){
// 				dp[j] = 0 ;
// 			}
// 		}
// 	}
// }

int main(){
	fastio
	start() ;
	// sieve() ;
	int t ;
	cin >> t ;
	while(t--){
		int n ;
		cin >> n ;
		int* a = new int[n] ;
		for(int i = 0 ; i < n ; i++){
			cin >> a[i] ;
		}
		int diff = 0 , even = 0;
		if(n<=11){
			cout << n << endl ;
			for(int i = 1 ; i <= n ; i++){
				cout << i << " " ;
			}
			cout << endl ;
			// continue ;
		}
		else{
			vector<int> v;
			int start = 2 ;
			vector< pair<int,int> > vec;
			for(int i = 0 ; i < n ; i++){
				if(a[i]==1){
					v.pb(start) ;
					start++;
					continue ;
				}
				if(!(a[i]&1)){
					v.pb(1) ;
					even++;
				}
				// else if(dp[a[i]] && a[i]&1){
				// 	v.pb(start) ;
				// 	start++;
				// }
				else{
					int flag = 0 ;
					for(int j = 0 ; j < vec.size() ; j++){
						if((a[i]%vec[j].first)==0){
							// cout << "dfhvk" << endl ;
							// cout << a[i] << " " << j << endl ;
							v.push_back(vec[j].second) ;
							flag = 1 ;
							break ;
						}
					}
					int temp = 0 ;
					if(!flag){
						// diff++;
						for(int j = 3 ; j*j <= a[i] ; j++){
								if(a[i]%j==0){
									// cout << "dbfvirf" << endl ;
									// cout << a[i] << " " << j << endl ;
									vec.pb(make_pair(j,start)) ;
									temp = 1 ;
							    }
						}
						if(!temp){
							vec.pb(mp(a[i],start)) ;
							v.pb(start) ;
							start++;
						}
						else{
							v.pb(start) ;
							start++ ;
							temp = 0 ;
						}
					}

				}
			}
			if(even)
				diff++ ;
			cout << diff+start-2 << endl ;
			for(int i = 0 ; i < v.size(); i++){
				cout << v[i] << " " ;
			}
			cout << endl ;
		}

	}

	return 0 ;
}


#include<bits/stdc++.h>

using namespace std ;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define pb push_back
#define pf push_front
#define mp make_pair

void start()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin);
        freopen("output.txt" , "w" , stdout);
    #endif
}

// int n = 10e8;
// int* dp = new int[n] ;

// void sieve(){

// 	for(int i = 0 ; i < n ; i++){
// 		dp[i] = 1 ;
// 	}
// 	dp[0] = 0 ;
// 	dp[1] = 0 ;
// 	for(int i  = 2 ; i*i <= n ; i++){
// 		if(dp[i]){
// 			for(int j = i*i ; j<=n ; j+=i){
// 				dp[j] = 0 ;
// 			}
// 		}
// 	}
// }

int main(){
	fastio
	start() ;
	// sieve() ;
	int t ;
	cin >> t ;
	while(t--){
		int n ;
		cin >> n ;
		int* a = new int[n] ;
		for(int i = 0 ; i < n ; i++){
			cin >> a[i] ;
		}
		int diff = 0 , even = 0;
		if(n<=11){
			cout << n << endl ;
			for(int i = 1 ; i <= n ; i++){
				cout << i << " " ;
			}
			cout << endl ;
			// continue ;
		}
		else{
			vector<int> v;
			int start = 1 ;
			vector< pair<int,int> > vec;
			for(int i = 0 ; i < n ; i++){
				if(a[i]==1){
					v.pb(start) ;
					start++;
					continue ;
				}
				// else if(dp[a[i]] && a[i]&1){
				// 	v.pb(start) ;
				// 	start++;
				// }
				else{
					int flag = 0 ;
					for(int j = 0 ; j < vec.size() ; j++){
						if((a[i]%vec[j].first)==0){
							// cout << "dfhvk" << endl ;
							// cout << a[i] << " " << j << endl ;
							v.push_back(vec[j].second) ;
							flag = 1 ;
							break ;
						}
					}
					int temp = 0 ;
					if(!flag){
						// diff++;
						for(int j = 3 ; j*j <= a[i] ; j++){
								if(a[i]%j==0){
									// cout << "dbfvirf" << endl ;
									// cout << a[i] << " " << j << endl ;
									vec.pb(make_pair(j,start)) ;
									temp = 1 ;
							    }
						}
						if(!temp){
							vec.pb(mp(a[i],start)) ;
							v.pb(start) ;
							start++;
						}
						else{
							v.pb(start) ;
							start++ ;
							temp = 0 ;
						}
					}

				}
			}
			int * x = new int[11] ;
			for(int i = 0 ; i < v.size() ; i++){
				x[v[i]-1]++ ;
			}
			for(int i = 0 ; i < 11 ; i++){
				if(x[i]){
					diff++ ;
				}
			}
			cout << diff << endl ;
			for(int i = 0 ; i < v.size(); i++){
				cout << v[i] << " " ;
			}
			cout << endl ;
		}

	}

	return 0 ;
}


#include<bits/stdc++.h>

using namespace std ;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define pb push_back
#define pf push_front
#define mp make_pair

void start()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin);
        freopen("output.txt" , "w" , stdout);
    #endif
}

int main(){
	fastio
	start() ;
	int t ;
	cin >> t ;
	while(t--){
		int n ;
		cin >> n ;
		int* a = new int[n] ;
		for(int i = 0 ;i < n; i++){
			cin >> a[i] ;
		}
		int arr[] = {2,3,5,7,11,13,17,19,23,29,31} ;
		// int brr[] = {1,2,3,4,5,6,7,8,9,10,11} ;
		int* brr = new int[11]() ;
		int x = 1 ;
		// int* count = new int[11]() ;
		for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < 11 ;j++){
				if(a[i]%arr[j]==0){
					if(!brr[j]){
						brr[j]	= x ;
						x++;
					}
					a[i]=brr[j];
					break;
				}
			}
		}
		int* max = max_element(a,a+n) ;
		cout << *max << endl ;
		for(int i = 0 ; i < n  ;i++){
			cout << a[i] << " " ;
		}
		cout << endl ;
	}

	return 0 ;
}


#include<bits/stdc++.h>

using namespace std ;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define pb push_back
#define pf push_front
#define mp make_pair

void start()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin);
        freopen("output.txt" , "w" , stdout);
    #endif
}

// int n = 10e8;
// int* dp = new int[n] ;

// void sieve(){

// 	for(int i = 0 ; i < n ; i++){
// 		dp[i] = 1 ;
// 	}
// 	dp[0] = 0 ;
// 	dp[1] = 0 ;
// 	for(int i  = 2 ; i*i <= n ; i++){
// 		if(dp[i]){
// 			for(int j = i*i ; j<=n ; j+=i){
// 				dp[j] = 0 ;
// 			}
// 		}
// 	}
// }

int main(){
	fastio
	start() ;
	// sieve() ;
	int t ;
	cin >> t ;
	while(t--){
		int n ;
		cin >> n ;
		int* a = new int[n] ;
		for(int i = 0 ; i < n ; i++){
			cin >> a[i] ;
		}
		int diff = 0 , even = 0;
		if(n<=11){
			cout << n << endl ;
			for(int i = 1 ; i <= n ; i++){
				cout << i << " " ;
			}
			cout << endl ;
			// continue ;
		}
		else{
			vector<int> v;
			int start = 1 ;
			vector< pair<int,int> > vec;
			for(int i = 0 ; i < n ; i++){
				if(a[i]==1){
					v.pb(start) ;
					start++;
					continue ;
				}
				// else if(dp[a[i]] && a[i]&1){
				// 	v.pb(start) ;
				// 	start++;
				// }
				else{
					int flag = 0 ;
					for(int j = 0 ; j < vec.size() ; j++){
						if((a[i]%vec[j].first)==0){
							// cout << "dfhvk" << endl ;
							// cout << a[i] << " " << j << endl ;
							v.push_back(vec[j].second) ;
							flag = 1 ;
							break ;
						}
					}
					int temp = 0 ;
					if(!flag){
						// diff++;
						for(int j = 3 ; j*j <= a[i] ; j++){
								if(a[i]%j==0){
									// cout << "dbfvirf" << endl ;
									// cout << a[i] << " " << j << endl ;
									vec.pb(make_pair(j,start)) ;
									temp = 1 ;
							    }
						}
						if(!temp){
							vec.pb(mp(a[i],start)) ;
							v.pb(start) ;
							start++;
						}
						else{
							v.pb(start) ;
							start++ ;
							temp = 0 ;
						}
					}

				}
			}
			int * x = new int[12]() ;
			for(int i = 0 ; i < v.size() ; i++){
				x[v[i]]++ ;
			}
			for(int i = 0 ; i < 11 ; i++){
				if(x[i]){
					diff++ ;
				}
			}
			cout << diff << endl ;
			for(int i = 0 ; i < v.size(); i++){
				cout << v[i] << " " ;
			}
			cout << endl ;
		}

	}

	return 0 ;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int x[n];int y[n];int h[n];
        for(int a=0;a<n;a++){y[a]=0;cin>>x[a];}
        sort(x,x+n);
    int z[x[n-1]+1],j[x[n-1]+1];
    for(int a=1;a<x[n-1]+1;a++)z[a]=0;

    for(int a=0;a<n;a++){
        for(int b=2;b<x[a];b++){
            if(x[a]%b==0){z[b]++;j[b]=b;

           break;}
    }}
    for(int a=0;a<x[n-1]+1;a++){
        for(int b=1;b<x[n-1];b++){
if(z[b]>z[b+1]){swap(z[b],z[b+1]);swap(j[b+1],j[b]);}
        }
    }
    int count=1;//cout<<[x[n-1]]<<endl;
    for(int a=x[n-1];a>=1;a--){int l=0;//cout<<z[a]<<endl;
    if(z[a]==0)break;
    for(int b=0;b<n;b++){
        if(y[b]==0 && x[b]%j[a]==0){
            h[b]=count;y[b]=1;l++;//cout<<h[b]<<" ";
        }//cout<<endl;

    }if(l!=0)count++;
    }
    //count=0;for(int a=0;a<n;a++)count=max(count,h[a]);
    cout<<count-1<<endl;
    for(int a=0;a<n;a++)cout<<h[a]<<" ";
    cout<<endl;
    }
        return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int x[n],y[n],z[n];
        for(int a=0;a<n;a++){z[a]=0;cin>>x[a];}
        int count=1;
        for(int a=0;a<n;a++){
       if(z[a]==0){     for(int b=a+1;b<n;b++){
                if(__gcd(x[a],x[b])!=1 && z[b]==0){
                    z[b]=1;y[b]=count;
                }
            }
           z[a]=1;y[a]=count;count++;
       }

        }
        cout<<count-1<<endl;
        for(int a=0;a<n;a++)cout<<y[a]<<" ";
        cout<<endl;
    }//cout<<__gcd(519,865);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int x[n],y[n],z[n];
        for(int a=0;a<n;a++){z[a]=0;cin>>x[a];}
        int count=1;
        for(int a=0;a<n;a++){
       if(z[a]==0){  int h[n],k=0;int d=0;h[k++]=x[a];
         for(int b=a+1;b<n;b++){
                for(int c=0;c<k;c++){if(z[b]==0){
                if(__gcd(h[c],x[b])!=1  ){
                  d++;
                }
                else break;}
                if(d==k){z[b]=1;y[b]=count;h[k++]=y[b];}
            }}
           z[a]=1;y[a]=count;count++;
       }

        }
        cout<<count-1<<endl;
        for(int a=0;a<n;a++)cout<<y[a]<<" ";
        cout<<endl;
    }//cout<<__gcd(391,697);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int x[n];int y[n];int h[n];
        for(int a=0;a<n;a++){y[a]=0;cin>>x[a];}
        sort(x,x+n);
    int z[x[n-1]+1];
    for(int a=1;a<x[n-1]+1;a++)z[a]=0;
    for(int a=0;a<n;a++){
        for(int b=2;b<=sqrt(x[a])+1;b++){
            if(x[a]%b==0){z[b]++;
            if(b!=x[a]/b)z[x[a]/b]++;
        }
    }}
    sort(z+1,z+x[n-1]+1);int count=1;
    for(int a=x[n-1]+1;a>=1;a--){int l=0;
    for(int b=0;b<n;b++){
        if(y[b]==0 && x[b]%z[a]==0){
            h[b]=count;y[b]=1;l++;
        }
    }if(l!=0)count++;
    }
    cout<<count-1<<endl;
    for(int a=0;a<n;a++)cout<<h[a]<<" ";
    cout<<endl;
    }
        return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ins insert
#define vi vector<int>
#define vl vector<ll>
#define lu unsigned long long
#define ff first
#define ss second
#define mod 1000000000
bool prime(int n)
{
    if(n==1||n==0)
        return false;
    else if(n==2||n==3)
        return true;
    else if(n%2==0||n%3==0)
        return false;
    else
    {
        for(int i=5;i*i<=n;i+=6)
        {
            if(n%i==0||n%(i+2)==0)
                return false;
        }
        return true;
    }
}
int main()
{
   int t;
   cin>>t;

   while(t--)
   {
       int n;
       cin>>n;

       int a[n];
       for(int i=0;i<n;i++)
           cin>>a[i];
       int p[n];
       for(int i=0;i<n;i++)
         p[i]=1;

       int c=1;
       int maxi=1;
       for(int i=0;i<n;i++)
       {
           for(int j=i+1;j<n;j++)
           {
               if(__gcd(a[i],a[j])==1&&p[i]==p[j])
               {
                   c=(c+1)%12;
                   if(c==0)
                    c++;
                   p[i]=c;
                    maxi=max(maxi,c);
               }
           }
       }
       cout<<maxi<<"\n";
       for(int i=0;i<n;i++)
        cout<<p[i]<<" ";
        cout<<"\n";
   }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ins insert
#define vi vector<int>
#define vl vector<ll>
#define lu unsigned long long
#define ff first
#define ss second
#define mod 1000000000
bool prime(int n)
{
    if(n==1||n==0)
        return false;
    else if(n==2||n==3)
        return true;
    else if(n%2==0||n%3==0)
        return false;
    else
    {
        for(int i=5;i*i<=n;i+=6)
        {
            if(n%i==0||n%(i+2)==0)
                return false;
        }
        return true;
    }
}
int main()
{
   int t;
   cin>>t;

   while(t--)
   {
       int n;
       cin>>n;

       int a[n],p[n];
       int maxi=0;
       for(int i=0;i<n;i++)
       {
        cin>>a[i];
         p[i]=1;
       }
       int c=1;
       for(int i=0;i<n;i++)
       {  maxi=max(maxi,c);
           if(prime(a[i]))
           {
               if(p[i]==c)
               {
                c=(c+1)%12;
                if(c==0)
                    c++;
                  p[i]=c;
               }
               continue;
           }

            for(int j=i+1;j<n;j++)
            {
                if(__gcd(a[i],a[j])==1&&p[i]==p[j])
                {
                    c=(c+1)%12;
                    if(c==0)
                        c+=1;
                    p[j]=c;
                }
                maxi=max(maxi,c);
            }
       }
       cout<<maxi<<"\n";
       for(int i=0;i<n;i++)
           cout<<p[i]<<" ";
       cout<<"\n";
   }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ins insert
#define vi vector<int>
#define vl vector<ll>
#define lu unsigned long long
#define ff first
#define ss second
#define mod 1000000000
bool prime(int n)
{
    if(n==1||n==0)
        return false;
    else if(n==2||n==3)
        return true;
    else if(n%2==0||n%3==0)
        return false;
    else
    {
        for(int i=5;i*i<=n;i+=6)
        {
            if(n%i==0||n%(i+2)==0)
                return false;
        }
        return true;
    }
}
int main()
{
   int t;
   cin>>t;

   while(t--)
   {
       int n;
       cin>>n;

       int a[n],p[n];
       for(int i=0;i<n;i++)
       {
        cin>>a[i];
         p[i]=1;
       }
       int c=1;
       for(int i=0;i<n;i++)
       {
           if(prime(a[i]))
           {
               if(p[i]==c)
               {
                c=(c+1)%12;
                if(c==0)
                    c++;
                  p[i]=c;
               }
               continue;
           }

            for(int j=i+1;j<n;j++)
            {
                if(__gcd(a[i],a[j])==1&&p[i]==p[j])
                {
                    c=(c+1)%12;
                    if(c==0)
                        c+=1;
                    p[j]=c;
                }
            }
       }
       for(int i=0;i<n;i++)
           cout<<p[i]<<" ";
       cout<<"\n";
   }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ins insert
#define vi vector<int>
#define vl vector<ll>
#define lu unsigned long long
#define ff first
#define ss second
#define mod 1000000000
bool prime(int n)
{
    if(n==1||n==0)
        return false;
    else if(n==2||n==3)
        return true;
    else if(n%2==0||n%3==0)
        return false;
    else
    {
        for(int i=5;i*i<=n;i+=6)
        {
            if(n%i==0||n%(i+2)==0)
                return false;
        }
        return true;
    }
}
int main()
{
   int t;
   cin>>t;

   while(t--)
   {
       int n;
       cin>>n;

       int a[n];
       for(int i=0;i<n;i++)
           cin>>a[i];
       int p[n];
       for(int i=0;i<n;i++)
         p[i]=1;

       int c=1;
       int maxi=1;
       for(int i=0;i<n;i++)
       {
           for(int j=i+1;j<n;j++)
           {
               if(__gcd(a[i],a[j])==1&&p[i]==p[j])
               {
                   c=(c+1)%12;
                   if(c==0)
                    c++;
                   p[j]=c;
                    maxi=max(maxi,c);
               }
           }
       }
       cout<<maxi<<"\n";
       for(int i=0;i<n;i++)
        cout<<p[i]<<" ";
        cout<<"\n";
   }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ins insert
#define vi vector<int>
#define vl vector<ll>
#define lu unsigned long long
#define ff first
#define ss second
#define mod 1000000000
int ab[]={2,3,5,7,11,13,17,19,23,29,31};
int main()
{
   int t;
   cin>>t;

   while(t--)
   {
       int n;
       cin>>n;

       int a[n];
       for(int i=0;i<n;i++)
        cin>>a[i];

       int p[n];
       for(int i=0;i<n;i++)
          p[i]=0;
       int c=0;
       for(int i=0;i<11;i++)
       {   int flag=0;
           int q=ab[i];
           for(int j=0;j<n;j++)
           {
               if(a[j]%q==0&&p[j]==0)
               {
                  p[j]=i+1;
                   flag=1;
               }
           }
           if(flag)
              c++;
       }
       cout<<c<<"\n";
       for(int i=0;i<n;i++)
            cout<<p[i]<<" ";
       cout<<"\n";
   }
   return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ins insert
#define vi vector<int>
#define vl vector<ll>
#define lu unsigned long long
#define ff first
#define ss second
#define mod 1000000000
int ab[]={2,3,5,7,11,13,17,19,23,29,31};
int main()
{
   int t;
   cin>>t;

   while(t--)
   {
       int n;
       cin>>n;

       int a[n];
       for(int i=0;i<n;i++)
        cin>>a[i];

       int p[n];
       for(int i=0;i<n;i++)
          p[i]=0;
       int c=1;
       for(int i=0;i<11;i++)
       {   int flag=0;
           int q=ab[i];
           for(int j=0;j<n;j++)
           {
              if(p[j]!=0)
                continue;
              if(a[j]%q)
                continue;
              flag=1;
              p[j]=c;
           }
           if(flag)
              c++;
       }
       cout<<c-1<<"\n";
       for(int i=0;i<n;i++)
            cout<<p[i]<<" ";
       cout<<"\n";
   }
   return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ins insert
#define vi vector<int>
#define vl vector<ll>
#define lu unsigned long long
#define ff first
#define ss second
#define mod 1000000000
bool prime(int n)
{
    if(n==1||n==0)
        return false;
    else if(n==2||n==3)
        return true;
    else if(n%2==0||n%3==0)
        return false;
    else
    {
        for(int i=5;i*i<=n;i+=6)
        {
            if(n%i==0||n%(i+2)==0)
                return false;
        }
        return true;
    }
}
int main()
{
   int t;
   cin>>t;

   while(t--)
   {
       int n;
       cin>>n;

       int a[n];
       for(int i=0;i<n;i++)
           cin>>a[i];
       int p[n];
       for(int i=0;i<n;i++)
         p[i]=0;

       int c=0;
       int maxi=1;
       for(int i=0;i<n;i++)
       {
           if(p[i]==0)
           {
             c++;
             p[i]=c;
           }
           for(int j=i+1;j<n;j++)
           {
               if(__gcd(a[i],a[j])>1&&p[j]==0)
                    p[j]=p[i];
           }
       }
      for(int i=0;i<n;i++)
        maxi=max(maxi,p[i]);
      cout<<maxi<<"\n";
       for(int i=0;i<n;i++)
        cout<<p[i]<<" ";
        cout<<"\n";
   }
    return 0;
}


// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define repp(i, a, b) for(int i = a; i <= b; i++)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, b, a) for(int i = b; i >= a; i--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(m) repp(i, 1, m){ll a, b; cin >> a >> b; v[a].pb(b), v[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define endl "\n"
ll power(ll x, ll y);

const ll MOD = 1000000007;

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    bool prm[1003];
    vector<ll> prime;
    rep(i, 0, 1003) prm[i] = 1;
    repp(i, 2, 1000) if(prm[i]){
        prime.pb(i);
        for(int j = 2*i; j <= 1000; j += i) prm[j] = 0;
    }

    ll t;
    cin >> t;
    while(t--){
        ll n;
        cin >> n;
        ll col[n];
        set<ll> st;
        rep(i, 0, n){
            ll x;
            cin >> x;
            rep(j, 0, 11) if(x % prime[j] == 0){
                col[i] = j;
                break;
            }
            st.insert(col[i]);
        }
        cout << st.size() << endl;
        rep(i, 0, n) cout << col[i] + 1 << " "; cout << endl;
    }

}

ll power(ll x, ll y)
{
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;}
    return res;
}


// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define repp(i, a, b) for(int i = a; i <= b; i++)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, b, a) for(int i = b; i >= a; i--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(m) repp(i, 1, m){ll a, b; cin >> a >> b; v[a].pb(b), v[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define endl "\n"
ll power(ll x, ll y);

const ll MOD = 1000000007;

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    ll t;
    cin >> t;
    while(t--){
        ll n;
        cin >> n;
        ll arr[n];
        rep(i, 0, n) cin >> arr[i];
        ll col[n];
        mem0(col);
        ll m = 0;

        set<ll> st;

        sort(arr, arr + n);
        rep(i, 0, n){
            if(col[i]) continue;
            ll x = arr[i];
            m++;
            m %= 11;
            col[i] = m + 1;
            st.insert(col[i]);
            rep(j, (i + 1), n){
                if(col[j] || arr[j] % x) continue;
                m++;
                m %= 11;
                col[j] = m + 1;
                st.insert(col[j]);
            }
        }

        cout << st.size() << endl;
        rep(i, 0, n) cout << col[i] << " ";
        cout << endl;

    }
}

ll power(ll x, ll y)
{
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;}
    return res;
}


// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define repp(i, a, b) for(int i = a; i <= b; i++)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, b, a) for(int i = b; i >= a; i--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(m) repp(i, 1, m){ll a, b; cin >> a >> b; v[a].pb(b), v[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define endl "\n"
ll power(ll x, ll y);

const ll MOD = 1000000007;

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    ll t;
    cin >> t;
    while(t--){
        ll n;
        cin >> n;
        pair<ll, ll> arr[n];
        rep(i, 0, n){
            cin >> arr[i].ff;
            arr[i].ss = i;
        }
        ll col[n];
        rep(i, 0, n) col[i] = 1;

        set<ll> st;

        sort(arr, arr + n);
        rep(i, 0, n){
            ll val = arr[i].ff;
            ll idx = arr[i].ss;
            rep(j, (i + 1), n){
                if(arr[j].ff % val == 0) col[arr[j].ss]++;
            }
        }

        ll mx = 0;
        rep(i, 0, n) mx = max(mx, col[i]);
        cout << mx << endl;
        rep(i, 0, n) cout << col[i] << " ";
        cout << endl;

    }
}

ll power(ll x, ll y)
{
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;}
    return res;
}


// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define repp(i, a, b) for(int i = a; i <= b; i++)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, b, a) for(int i = b; i >= a; i--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(m) repp(i, 1, m){ll a, b; cin >> a >> b; v[a].pb(b), v[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define endl "\n"
ll power(ll x, ll y);

const ll MOD = 1000000007;

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    ll t;
    cin >> t;
    while(t--){
        ll n;
        cin >> n;
        pair<ll, ll> arr[n];
        rep(i, 0, n){
            cin >> arr[i].ff;
            arr[i].ss = i;
        }
        ll col[n];
        mem0(col);
        ll m = 0;

        set<ll> st;

        sort(arr, arr + n);
        rep(i, 0, n){
            if(col[arr[i].ss]) continue;
            ll x = arr[i].ff;
            m = (m + 1) % 11;
            col[arr[i].ss] = m + 1;
            st.insert(m);
            rep(j, (i + 1), n){
                if(col[arr[i].ss] || arr[j].ff % x) continue;
                m = (m + 1) % 11;
                col[arr[i].ss] = m + 1;
                st.insert(m);
            }
        }

        cout << st.size() << endl;
        rep(i, 0, n) cout << col[i] << " ";
        cout << endl;

    }
}

ll power(ll x, ll y)
{
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;}
    return res;
}


// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define repp(i, a, b) for(int i = a; i <= b; i++)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, b, a) for(int i = b; i >= a; i--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(m) repp(i, 1, m){ll a, b; cin >> a >> b; v[a].pb(b), v[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define endl "\n"
ll power(ll x, ll y);

const ll MOD = 1000000007;

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    bool prm[1003];
    vector<ll> prime;
    rep(i, 0, 1003) prm[i] = 1;
    repp(i, 2, 1000) if(prm[i]){
        prime.pb(i);
        for(int j = 2*i; j <= 1000; j += i) prm[j] = 0;
    }

    ll t;
    cin >> t;
    while(t--){
        ll n;
        cin >> n;
        ll col[n];
        set<ll> st;
        rep(i, 0, n){
            ll x;
            cin >> x;
            rep(j, 0, 11) if(x % prime[j]) col[i] = j;
            st.insert(col[i]);
        }
        cout << st.size() << endl;
        rep(i, 0, n) cout << col[i] << " "; cout << endl;
    }

}

ll power(ll x, ll y)
{
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;}
    return res;
}


// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define repp(i, a, b) for(int i = a; i <= b; i++)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, b, a) for(int i = b; i >= a; i--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(m) repp(i, 1, m){ll a, b; cin >> a >> b; v[a].pb(b), v[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define endl "\n"
ll power(ll x, ll y);

const ll MOD = 1000000007;

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    ll t;
    cin >> t;
    while(t--){
        ll n;
        cin >> n;
        pair<ll, ll> arr[n];
        rep(i, 0, n){
            cin >> arr[i].ff;
            arr[i].ss = i;
        }
        ll col[n];
        mem0(col);
        ll m = 0;

        set<ll> st;

        sort(arr, arr + n);
        rep(i, 0, n){
            if(col[arr[i].ss]) continue;
            ll x = arr[i].ff;
            m = (m + 1) % 11;
            col[arr[i].ss] = m + 1;
            st.insert(m);
            rep(j, (i + 1), n){
                if(col[arr[j].ss] || arr[j].ff % x) continue;
                m = (m + 1) % 11;
                col[arr[j].ss] = m + 1;
                st.insert(m);
            }
        }

        cout << st.size() << endl;
        rep(i, 0, n) cout << col[i] << " ";
        cout << endl;

    }
}

ll power(ll x, ll y)
{
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;}
    return res;
}


// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define repp(i, a, b) for(int i = a; i <= b; i++)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, b, a) for(int i = b; i >= a; i--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(m) repp(i, 1, m){ll a, b; cin >> a >> b; v[a].pb(b), v[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define endl "\n"
ll power(ll x, ll y);

const ll MOD = 1000000007;

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    bool prm[1003];
    vector<ll> prime;
    rep(i, 0, 1003) prm[i] = 1;
    repp(i, 2, 1000) if(prm[i]){
        prime.pb(i);
        for(int j = 2*i; j <= 1000; j += i) prm[j] = 0;
    }

    // rep(i, 0, 11) cout << prime[i] << ' 'c;

    ll t;
    cin >> t;
    while(t--){
        ll n;
        cin >> n;
        ll col[n];
        set<ll> st;
            ll f = 1;
            map<ll, ll> m;
        rep(i, 0, n){
            ll x;
            cin >> x;
            rep(j, 0, 11) if(x % prime[j] == 0){
                if(m[j] == 0) m[j] = f++;
                col[i] = m[j];
                break;
            }
            st.insert(col[i]);
        }

        cout << st.size() << endl;
        rep(i, 0, n) cout << col[i] << " "; cout << endl;
    }

}

ll power(ll x, ll y)
{
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;}
    return res;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    int t,n;
    cin>>t;
    while(t--){
        cin>>n;
        int a[n],c[n]={0};
        vector<int>v[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n;i++){
            for(int j=i;j<n;j++){
                if(i!=j){
                    int g=__gcd(a[i],a[j]);
                    if(g>1)
                    v[i].push_back(j);
                }
                else{
                    v[i].push_back(i);
                }
            }
        }
        int mm=1;
        for(int i=0;i<n;i++){
            int vs=v[i].size();
            if(c[i]==0){
            if(vs==1){
                c[v[i][0]]=mm;
            }
            else{
                for(int j=0;j<vs;j++){
                    c[v[i][j]]=mm;
                }
            }

            mm++;
            }
        }
        cout<<mm-1<<endl;
        for(int i=0;i<n;i++){
            cout<<c[i]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    int t,n;
    cin>>t;
    while(t--){
        cin>>n;
        int a[n],b[n]={0};
        vector<int>v[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n;i++){
            if(b[i]==0){
            for(int j=0;j<n;j++){
                if(i!=j){
                    int g = __gcd(a[i],a[j]);
                    //cout<<g<<endl;
                    if(g>1){
                        //cout<<g<<endl;
                        b[j]=1;
                        v[i].push_back(j);
                    }
                }
            }
            }
        }
        int mm=1,c[n]={0},d[n]={0};
        for(int i=0;i<n;i++){
            int vs = v[i].size();
            //cout<<vs<<endl;
            if(vs==0 && d[i]==0){
                c[i]=mm;
            }
            else if(vs==0 && d[i]==1){
                continue;
            }
            else{
                c[i]=mm;
                for(int j=0;j<vs;j++){
                    //cout<<"v[i][j] "<<v[i][j]<<endl;
                    int tind=v[i][j];
                    d[tind]=1;
                    c[tind]=mm;
                }
            }
            mm++;
        }
        cout<<mm-1<<endl;
        for(int i=0;i<n;i++){
            cout<<c[i]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
    ll t,n;
    cin>>t;
    while(t--){
        cin>>n;
        ll a[n],b[11]={2,3,5,7,11,13,17,19,23,29,31},ans[1001]={0};
        for(ll i=0;i<n;i++){
            cin>>a[i];
            for(ll j=0;j<11;j++){
                if(a[i]%b[j]==0){
                    ans[a[i]]=j+1;
                    break;
                }
            }
        }
        cout<<"11"<<endl;
        for(ll i=0;i<n;i++){
            cout<<ans[a[i]]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
    ll t,n;
    cin>>t;
    while(t--){
        cin<<n;
        ll a[n],b[11]={2,3,5,7,11,13,17,19,23,29,31},ans[1001]={0};
        for(ll i=0;i<n;i++){
            cin>>a[i];
            for(ll j=0;j<11;j++){
                if(a[i]%b[j]==0){
                    ans[a[i]]=j+1;
                    break;
                }
            }
        }
        cout<<"11"<<endl;
        for(ll i=0;i<n;i++){
            cout<<ans[a[i]]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
    ll t,n,ans[1001]={0};
    cin>>t;
    while(t--){
        ll a[n],b[11]={2,3,5,7,11,13,17,19,23,29,31};
        for(ll i=0;i<n;i++){
            cin>>a[i];
            for(ll j=0;j<11;j++){
                if(a[i]%b[j]==0){
                    ans[a[i]]=j+1;
                    break;
                }
            }
        }
        cout<<"11"<<endl;
        for(ll i=0;i<n;i++){
            cout<<ans[a[i]]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    int t,n;
    cin>>t;
    while(t--){
        cin>>n;
        int a[n],b[n]={0};
        vector<int>v[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n;i++){
            if(b[i]==0){
            for(int j=0;j<n;j++){
                if(i!=j){
                    int g = __gcd(a[i],a[j]);
                    //cout<<g<<endl;
                    if(g>1){
                        //cout<<g<<endl;
                        b[j]=1;
                        v[i].push_back(j);
                    }
                }
            }
            }
        }
        int mm=1,c[n]={0},d[n]={0};
        for(int i=0;i<n;i++){
            int vs = v[i].size();
            //cout<<vs<<endl;
            if(vs==0 && d[i]==0){
                c[i]=mm;
            }
            else if(vs==0 && d[i]==1){
                continue;
            }
            else{
                c[i]=mm;
                for(int j=0;j<vs;j++){
                    //cout<<"v[i][j] "<<v[i][j]<<endl;
                    int tind=v[i][j];
                    d[tind]=1;
                    c[tind]=mm;
                }
            }
            mm++;
        }
        for(int i=0;i<n;i++){
            cout<<c[i]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#include <vector>
#include <cstdio>
#include <string>
using namespace std;
typedef long long ll;
int main()
{
	int t;
	cin >> t;
	while ( t-- )
	{
		int n;
		cin>>n;
		int a[n];
		for(int i=0;i<n;i++)
			cin >>a[i];
		if(n<=11)
		{
			cout<<n<<endl;
			for(int i=0;i<n;i++)
				cout <<i+1<<" ";
			cout<<endl;
			continue;
		}
		int c[n];
		int b[]={2,3,5,7,11,13,17,19,23,31,37};int x=1;
		int d[11]={};
		for(int j=0;j<11;j++)
			d[j]=-1;
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<11;j++)
			{
				if(a[i]%b[j]==0 && d[j]==-1)
				{
					d[j]=x++;
					c[i]=b[j];
					break;
				}

			}

		}
//			for(int j=0;j<11;j++)
//			cout<<d[j]<<" ";
//			cout<<endl;
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<11;j++)
			{
				if(a[i]%b[j]==0)
				{
					flag=1;
					break;
				}

			}
			if(flag==0)
				c[i]=x++;
		}
		int mx=*max_element(c,c+n);
		cout<<mx<<endl;
		for(int i=0;i<n;i++)
				cout <<c[i]<<" ";
		cout<<endl;
	}
}


#include <bits/stdc++.h>
#include <vector>
#include <cstdio>
#include <string>
using namespace std;
typedef long long ll;
int main()
{
	int t;
	cin >> t;
	while ( t-- )
	{
		int n;
		cin>>n;
		int a[n];
		for(int i=0;i<n;i++)
			cin >>a[i];
		if(n<=11)
		{
			cout<<n<<endl;
			for(int i=0;i<n;i++)
				cout <<i+1<<" ";
			cout<<endl;
			continue;
		}
		int c[n];
		int b[]={2,3,5,7,11,13,17,19,23,31,37};int x=1;
		int d[11]={};
		for(int j=0;j<11;j++)
			d[j]=-1;
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<11;j++)
			{
				if(a[i]%b[j]==0 && d[j]==-1)
				{
					d[j]=x++;
					break;
				}

			}

		}
//			for(int j=0;j<11;j++)
//			cout<<d[j]<<" ";
//			cout<<endl;
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<11;j++)
			{
				if(a[i]%b[j]==0)
				{
					flag=1;
					break;
				}

			}
			if(flag==0)
				c[i]=x++;
		}
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<11;j++)
			{
				if(a[i]%b[j]==0)
				{
					c[i]=d[j];
					break;
				}
			}
		}
		int mx=*max_element(c,c+n);
		cout<<mx<<endl;
		for(int i=0;i<n;i++)
				cout <<c[i]<<" ";
		cout<<endl;
	}
}


#include <bits/stdc++.h>
#include <vector>
#include <cstdio>
#include <string>
using namespace std;
typedef long long ll;
int main()
{
	int t;
	cin >> t;
	while ( t-- )
	{
		int n;
		cin>>n;
		int a[n];
		for(int i=0;i<n;i++)
			cin >>a[i];
		if(n<=11)
		{
			cout<<n<<endl;
			for(int i=0;i<n;i++)
				cout <<i+1<<" ";
			cout<<endl;
			continue;
		}
		int x=1;int b[n]={0};
		for(int i=0;i<n;i++)
		{
			if(b[i]==0)
			b[i]=x;
			else
			x--;
			for(int j=i+1;j<n;j++)
			{
				int p=__gcd(a[i],a[j]);
//				cout<<p<< endl;
				if(p>1)
				{
					if(b[j]==0)
						b[j]=x;
				}
			}
			x++;
		}
		cout<<x<<endl;
		for(int i=0;i<n;i++)
		{

			cout<<b[i]<<" ";
		}
		cout<<endl;
			continue;
	}
}


#include <bits/stdc++.h>
#include <vector>
#include <cstdio>
#include <string>
using namespace std;
typedef long long ll;
int main()
{
	int t;
	cin >> t;
	while ( t-- )
	{
		int n;
		cin>>n;
		int a[n];
		for(int i=0;i<n;i++)
			cin >>a[i];
		if(n<=11)
		{
			cout<<n<<endl;
			for(int i=0;i<n;i++)
				cout <<i+1<<" ";
			cout<<endl;
			continue;
		}
		int c[n];
		int b[]={2,3,5,7,11,13,17,19,23,31,37};int x=1;
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<11;j++)
			{
				if(a[i]%b[j]==0)
				{
					flag=1;
					break;
				}

			}
			if(flag==0)
				c[i]=x++;
		}
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<12;j++)
			{
				if(a[i]%b[j]==0)
				{
					c[i]=x+j;
					break;
				}
			}
		}
		int mx=*max_element(c,c+n);
		cout<<mx<<endl;
		for(int i=0;i<n;i++)
				cout <<c[i]<<" ";
		cout<<endl;
	}
}