package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type CF1665A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1665A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1665A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1665A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1665A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1665A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1665A
Date: 28/04/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1665/A
Problem: CF1665A
**/
func (in *CF1665A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		fmt.Println(1, n-3, 1, 1)

	}
}

func NewCF1665A(r *bufio.Reader) *CF1665A {
	return &CF1665A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1665A(bufio.NewReader(os.Stdin)).Run()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// if it is an even number, then c and d will be 1 and 1 and we just need to find two primes number to a and b and a + b = n - 2

// if it is an odd number, then b and c and d will be 1, a will be n - 3 which is an even number

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())

	for i := 0; i < t; i++ {
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text())
		fmt.Printf("%d %d %d %d\n", n-3, 1, 1, 1)
	}

}

package main

import (
	"bufio"
	. "fmt"
	"os"
)

func main_div2_781_A() {
	_in, _out := os.Stdin, os.Stdout
	in, out := bufio.NewReader(_in), bufio.NewWriter(_out)
	defer out.Flush()
	var cas int = 1
	Fscan(in, &cas)
	var sol func()
	/* Begin Coding */
	sol = func() {
		var n int
		Fscan(in, &n)
		// if n == 6 {

		// 	return
		// }
		// if n%4 == 0 {
		// 	Fprintln(out, n/4, " ", n/4, " ", n/4, " ", n/4)
		// } else if n%4 == 1 || n%4 == 3 {
		// 	Fprintln(out, 1, " ", n-3, " ", 1, " ", 1)
		// } else {
		// 	Fprintln(out, 2, " ", n-6, " ", 2, " ", 2)
		// }
		Fprintln(out, n-3, " ", 1, " ", 1, " ", 1)
	}
	/* Code Ending */
	for i := 0; i < cas; i++ {
		sol()
	}

}

func main() {
	main_div2_781_A()
}

package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var t int
	fmt.Scan(&t)

	for ; t > 0; t-- {
		var n int64
		fmt.Scan(&n)

		if n == 4 {
			fmt.Println(1, 1, 1, 1)
		} else {
			fmt.Println(n-3, 1, 1, 1)
		}
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func main() {
	A(os.Stdin, os.Stdout)
}

func A(_r io.Reader, _w io.Writer) {
	in, out := bufio.NewReader(_r), bufio.NewWriter(_w)
	defer out.Flush()

	var c int
	var n int
	Fscan(in, &c)
	for ; c > 0; c-- {
		ans := [4]int{}
		Fscan(in, &n)
		if n%4 == 0 {
			for i := range ans {
				ans[i] = n / 4
			}
		} else {
			n -= 2
			if n%2 == 0 && n != 2 {
				ans[0] = n/2 - 1
				ans[1] = n/2 + 1
			} else {
				ans[0] = n / 2
				ans[1] = n/2 + 1
			}
			ans[2] = 1
			ans[3] = 1
		}
		Fprintf(out, "%d %d %d %d\n", ans[0], ans[1], ans[2], ans[3])
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var x int
		fmt.Fscan(in,&x)
		if x%4 == 0 {
			fmt.Fprintln(out, x/4,x/4,x/4,x/4)
			continue
		}
		fmt.Fprintln(out,x-3,1,1,1)
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var n int
		fmt.Scan(&n)
		fmt.Printf("%d %d %d %d\n", n-3, 1, 1, 1)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

const mod = 998244353

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var n int
	fmt.Fscan(in,&n)
	fmt.Fprintf(out,"%d %d %d %d\n",n-3,1,1,1)
}

func abs(a,b int)int{
	if a > b{
		return a - b
	}
	return b - a
}
func sum(a,b int64)int64{
	return (b + a) * (b - a + 1) / 2
}

func max(a,b int)int{
	if a > b{
		return a
	}
	return b
}
func min(a,b int)int{
	if a > b{
		return b
	}
	return a
}
func gcd(a,b int)int{
	if a % b == 0{
		return b
	}
	return gcd(b,a%b)
}

func main() {
	stdin := os.Stdin
	stdout := os.Stdout
	in := bufio.NewReader(stdin)
	out := bufio.NewWriter(stdout)
	n := 1
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		solve(in, out)
	}
}

package main

// Problem description URL https://atcoder.jp/contests/abc236/tasks/abc240_a

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }

type pair struct {
	Color int
	Size  int
}

var (
	n   = 0
	t   = 0
	a []int
	res []int
	s   *list.List
	cur = 0
)

func gcd(a int, b int) int {
	if a%b==0 {
		return b
	}
	return gcd(b, a%b)
}
func solve() {
	scan(&t)
	for t != 0 {
		t--
		scan(&n)
		if n%4 == 0 {
			printf("%d %d %d %d\n", n/4,n/4,n/4,n/4)
		}else {
			a,b := 1,n-3
			for ;a<n-2;a++{
				if gcd(a, b) == 1 {
					break
				}
				b--
			}
			printf("%d %d %d %d\n",  a,b,1,1)
		}
	}
}

func main() {
	defer out.Flush()
	solve()
}

package main

import "fmt"

func main() {
	var t int

	fmt.Scan(&t)

	for ; t > 0 ; t--  {

		var n int

		fmt.Scan(&n)

		fmt.Println(n - 3, 1, 1, 1);

	}

}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1665A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		Fprintln(out, n-3, 1, 1, 1)
	}
}

func main() { CF1665A(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var tests int
	_, _ = fmt.Fscan(reader, &tests)

	for t := 0; t < tests; t++ {
		var n int
		fmt.Fscan(reader, &n)
		fmt.Fprintln(writer, n-3, 1, 1, 1)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	var t int
	_, _ = fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		var n int
		_, _ = fmt.Fscan(reader, &n)
		var m = n - 2 - 1
		fmt.Printf("%v 1 1 1\n", m)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {

	reader := bufio.NewReader(os.Stdin)
	writter := bufio.NewWriter(os.Stdout)
	defer writter.Flush()

	t := 0
	fmt.Fscan(reader, &t)

	for t > 0 {
		n := 0
		fmt.Fscan(reader, &n)

		result := solve(n)

		for i := range result {
			fmt.Fprintf(writter, "%d ", result[i])
		}
		fmt.Fprintln(writter)

		t--
	}

	// n := 7
	// fmt.Println(solve(n))

	//ethereum.Ethereum()

}

func solve(n int) []int {

	result := []int{n - 3, 1, 1, 1}

	return result
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	sc *bufio.Scanner
	wr *bufio.Writer
)

func init() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	wr = bufio.NewWriter(os.Stdout)
}

func scanInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func scanStr() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	defer wr.Flush()
	T := scanInt()

	for ; T > 0; T-- {
		a, b, c, d := solve(scanInt())
		fmt.Fprintln(wr, a, b, c, d)
	}
}

func solve(n int) (int, int, int, int) {
	return 1, n - 3, 1, 1
}

package main

import (
	"bufio"
	. "fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var t int
	Fscan(in, &t)
	for ; t > 0; t-- {
		var n int
		Fscan(in, &n)
		// var solve func() = func ()  {
		// 	for i := 1; i <= n; i++ {
		// 		for j := 1; j <= n; j++ {
		// 			for k := 1; k <= n; k++ {
		// 				l := n - i - j - k
		// 				if l < 0 { break }
		// 				if gcd(i, j) == lcm(k, l) {
		// 					Fprintln(out, i, j, k, l)
		// 					return
		// 				}
		// 			}
		// 		}
		// 	}
		// }
		// solve()
		Fprintln(out, 1, n - 3, 1, 1)
	}
}

func min(a, b int) int { if a > b { return b }; return a }
func max(a, b int) int { if a < b { return b }; return a }
func abs(v int) int { if v > 0 { return v }; return -v }
func gcd(a, b int) int { if b > 0 { return gcd(b, a % b) }; return a }
func lcm(a, b int) int { return a * b / gcd(a, b) }

package main

import (
	"bufio"
	. "fmt"
	"os"
)

const (
	INF = 3e5 + 10
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var t int
	Fscan(in, &t)

	for i := 1; i <= t; i++ {
		var n int
		Fscan(in, &n)
		Fprintln(out, n-3, 1, 1, 1)

	}

}

package main

import (
	"bufio"
	"os"
	"fmt"
)

const MOD int64 = 1000000007

var n int

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

func (a ByV) Len() int           { return len(a) }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

	for i := 0; i < t; i++ {

		fmt.Fscan(read, &n)

		solve()
	}
}

type pair struct {
	v int
	idx []int
}

//a b c d

//20 12 -- 4
//4  2  -- 4

func solve()  {
	//c = k1 * p
	//d = k2 * p
	//

	//11

	//8 1 1 1

	fmt.Println(n - 3, 1, 1, 1)
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		fmt.Fprintln(out, n-3, 1, 1, 1)
	}
}

package main

import (
	"bufio"
	. "fmt"
	"os"
)

func main_div2_781_A() {
	_in, _out := os.Stdin, os.Stdout
	in, out := bufio.NewReader(_in), bufio.NewWriter(_out)
	defer out.Flush()
	var cas int = 1
	Fscan(in, &cas)
	var sol func()
	/* Begin Coding */
	sol = func() {
		var n int
		Fscan(in, &n)
		if n%4 == 0 {
			Fprintln(out, n/4, " ", n/4, " ", n/4, " ", n/4)
		} else if n%4 == 1 || n%4 == 3 {
			Fprintln(out, 2, " ", n-4, " ", 1, " ", 1)
		} else {
			Fprintln(out, 2, " ", n-6, " ", 2, " ", 2)
		}
	}
	/* Code Ending */
	for i := 0; i < cas; i++ {
		sol()
	}

}

func main() {
	main_div2_781_A()
}

package main

import (
	"bufio"
	. "fmt"
	"os"
)

func main_div2_781_A() {
	_in, _out := os.Stdin, os.Stdout
	in, out := bufio.NewReader(_in), bufio.NewWriter(_out)
	defer out.Flush()
	var cas int = 1
	Fscan(in, &cas)
	var sol func()
	/* Begin Coding */
	sol = func() {
		var n int
		Fscan(in, &n)
		if n%4 == 0 {
			Fprintln(out, n/4, " ", n/4, " ", n/4, " ", n/4)
		} else if n%4 == 1 || n%4 == 3 {
			Fprintln(out, 2, " ", n-4, " ", 1, " ", 1)
		} else {
			Fprintln(out, 3, " ", n-5, " ", 1, " ", 1)
		}
	}
	/* Code Ending */
	for i := 0; i < cas; i++ {
		sol()
	}

}

func main() {
	main_div2_781_A()
}

package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var t int
	fmt.Scan(&t)

	for ; t > 0; t-- {
		var n int64
		fmt.Scan(&n)

		if n == 4 {
			fmt.Println(1, 1, 1, 1)
		} else if n%2 == 0 {
			n = n - 2
			fmt.Println(n/2+1, n/2-1, 1, 1)
		} else {
			n = n - 2
			fmt.Println(n/2, n/2+1, 1, 1)
		}
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func main() {
	A(os.Stdin, os.Stdout)
}

func A(_r io.Reader, _w io.Writer) {
	in, out := bufio.NewReader(_r), bufio.NewWriter(_w)
	defer out.Flush()

	var c int
	var n int
	Fscan(in, &c)
	for ; c > 0; c-- {
		ans := [4]int{}
		Fscan(in, &n)
		if n%4 == 0 {
			for i := range ans {
				ans[i] = n / 4
			}
		} else {
			n -= 2
			ans[0] = n / 2
			ans[1] = n/2 + 1
			ans[2] = 1
			ans[3] = 1
		}
		Fprintf(out, "%d %d %d %d\n", ans[0], ans[1], ans[2], ans[3])
	}
}


// Author: sighduck
// URL: https://codeforces.com/problemset/problem/780/C

package main

import (
	"bufio"
	"fmt"
	"os"
)

type Edge struct {
	from int
	to   int
}

type Answer struct {
	maxColor int
	colors   []int
}

type Item struct {
	vertex      int
	color       int
	parentColor int
}

func Solve(n int, edges []Edge) Answer {
	graph := make(map[int][]int)
	for _, edge := range edges {
		graph[edge.from] = append(graph[edge.from], edge.to)
		graph[edge.to] = append(graph[edge.to], edge.from)
	}
	colors := make([]int, n+1)
	visited := make([]bool, n+1)
	visited[1] = true
	stack := []Item{{1, 1, 0}}
	for len(stack) > 0 {
		item := stack[len(stack)-1]
		stack = stack[:len(stack)-1]
		colors[item.vertex] = item.color
		i := 1
		for _, v := range graph[item.vertex] {
			if !visited[v] {
				visited[v] = true
				for item.parentColor == i || item.color == i {
					i += 1
				}
				stack = append(stack, Item{v, i, item.color})
				i += 1
			}
		}
	}
	maxColor := 0
	for _, elem := range colors {
		if elem > maxColor {
			maxColor = elem
		}
	}
	return Answer{maxColor, colors[1:]}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	edges := make([]Edge, n-1)
	for i := 0; i < n-1; i++ {
		fmt.Fscanf(reader, "%d %d\n", &edges[i].from, &edges[i].to)
	}

	ans := Solve(n, edges)
	fmt.Fprintf(writer, "%d\n", ans.maxColor)
	for _, elem := range ans.colors {
		fmt.Fprintf(writer, "%d ", elem)
	}
	fmt.Fprintf(writer, "\n")
}

package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

const (
	//MaxScanTokenSize = 64 * 1024 // package default
	MaxScanTokenSize = 8 * 1024 * 1024 // 8M
)

func init() {
	scanner.Buffer(make([]byte, 0, MaxScanTokenSize), MaxScanTokenSize)
	scanner.Split(bufio.ScanWords)
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

type Edge struct {
	From int
	To   int
	Cap  int
	Flow int
}

type Graph struct {
	NNode  int
	NEdge  int
	Edges  []Edge
	Nodes  [][]int

	Colors []int
}

func NewGraph(nNode, nEdge int) *Graph {
	g := &Graph{
		NNode: nNode,
		NEdge: nEdge,
		Edges: make([]Edge, 0, nEdge),
		Nodes: make([][]int, nNode, nNode),

		Colors: make([]int, nNode, nNode),
	}
	return g
}

func (g *Graph) AddEdge(from, to, cap, flow int) {
	g.Nodes[from] = append(g.Nodes[from], len(g.Edges))
	g.Edges = append(g.Edges, Edge{from, to, cap, flow})
	g.Nodes[to] = append(g.Nodes[to], len(g.Edges))
	g.Edges = append(g.Edges, Edge{to, from, cap, flow})
}

func (g *Graph) Show() {
	fmt.Printf("n node = %d, n edge = %d\n", g.NNode, g.NEdge)
	for i, cur := range g.Nodes {
		fmt.Printf("[%d]", i)
		for _, next := range cur {
			fmt.Printf(" %d", g.Edges[next].To)
		}
		fmt.Println()
	}
}

func paint(g *Graph, pre, cur int) {
	color := 1
	for _, ie := range g.Nodes[cur] {
		next := g.Edges[ie].To
		if pre == next {
			continue
		}
		for (pre != -1 && color == g.Colors[pre]) || (color == g.Colors[cur]) {
			color++
		}
		g.Colors[next] = color
		color++

		if pre != next {
			paint(g, cur, next)
		}
	}
}

func main() {
	n := readInt()
	g := NewGraph(n, n - 1)

	for i := 1; i < n; i++ {
		from, to := readInt(), readInt()
		g.AddEdge(from - 1, to - 1, 0, 0)
	}
	//g.Show()

	g.Colors[0] = 1
	paint(g, -1, 0)

	maxColor := 0
	for _, color := range g.Colors {
		if color > maxColor {
			maxColor = color
		}
	}
	fmt.Println(maxColor)
	for i := 0; i < n; i++ {
		fmt.Printf("%d ", g.Colors[i])
	}
	fmt.Println("")
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"math"
	"os"
	"strconv"
)

var res []int

type Vertex struct {
	color int
	adj   []*Vertex
}

func (v *Vertex) add(u *Vertex) {
	v.adj = append(v.adj, u)
}

func (v *Vertex) dfs(us int, skip int) {
	v.color = us
	nxt := 1
	for nxt == us || nxt == skip {
		nxt++
	}
	for _, next := range v.adj {
		if next.color == 0 {
			next.dfs(nxt, us)
			nxt++
			for nxt == us || nxt == skip {
				nxt++
			}
		}
	}
}

func solve() {
	n := readInt()
	vertexes := make([]*Vertex, n)
	for i := 0; i < n; i++ {
		vertexes[i] = &Vertex{0, make([]*Vertex, 0)}
	}
	for i := 0; i < n-1; i++ {
		x := readInt() - 1
		y := readInt() - 1
		vertexes[y].add(vertexes[x])
		vertexes[x].add(vertexes[y])
	}
	vertexes[0].dfs(1, 0)
	max := 0
	for _, v := range vertexes {
		if max < len(v.adj)+1 {
			max = len(v.adj) + 1
		}
	}
	fmt.Println(max)
	var buffer bytes.Buffer
	for i, v := range vertexes {
		if i > 0 {
			buffer.WriteString(" ")
		}
		buffer.WriteString(strconv.Itoa(v.color))
	}
	fmt.Println(buffer.String())
}

var scanner *bufio.Scanner

type MinHeap struct {
	a    []int
	vmap []int
	imap []int
	n    int
	pos  int
}

const INF = math.MaxInt32

func NewMinHeap(m int) *MinHeap {
	heap := &MinHeap{}
	m += 2
	heap.n = m
	heap.a = make([]int, heap.n)
	heap.vmap = make([]int, heap.n)
	heap.imap = make([]int, heap.n)
	heap.pos = 1
	for i := 0; i < heap.n; i++ {
		heap.a[i] = INF
		heap.vmap[i] = -1
		heap.imap[i] = -1
	}
	return heap
}

func (h *MinHeap) Add(ind, x int) int {
	ret := h.imap[ind]
	if h.imap[ind] < 0 {
		h.a[h.pos] = x
		h.vmap[h.pos] = ind
		h.imap[ind] = h.pos
		h.pos++
		h.up(h.pos - 1)
	}
	if ret != -1 {
		return h.a[ret]
	}
	return x
}

func (h *MinHeap) Update(ind, x int) int {
	ret := h.imap[ind]
	if h.imap[ind] < 0 {
		h.a[h.pos] = x
		h.vmap[h.pos] = ind
		h.imap[ind] = h.pos
		h.pos++
		h.up(h.pos - 1)
	} else {
		h.a[ret] = x
		h.up(ret)
		h.down(ret)
	}
	return x
}

func (h *MinHeap) Remove(ind int) int {
	if h.pos == 1 {
		return INF
	}
	if h.imap[ind] == -1 {
		return INF
	}

	h.pos--
	rem := h.imap[ind]
	ret := h.a[rem]
	h.vmap[rem] = h.vmap[h.pos]
	h.imap[h.vmap[h.pos]] = rem
	h.imap[ind] = -1
	h.a[rem] = h.a[h.pos]
	h.a[h.pos] = INF
	h.vmap[h.pos] = -1

	h.up(rem)
	h.down(rem)
	return ret
}

func (h *MinHeap) Min() int {
	return h.a[1]
}

func (h *MinHeap) ArgMin() int {
	return h.vmap[1]
}

func (h *MinHeap) Size() int {
	return h.pos - 1
}

func (h *MinHeap) up(cur int) {
	for c, p := cur, cur>>1; p >= 1 && h.a[p] > h.a[c]; c, p = c>>1, p>>1 {
		h.a[p], h.a[c] = h.a[c], h.a[p]
		h.imap[h.vmap[p]], h.imap[h.vmap[c]] = h.imap[h.vmap[c]], h.imap[h.vmap[p]]
		h.vmap[p], h.vmap[c] = h.vmap[c], h.vmap[p]
	}
}

func (h *MinHeap) down(cur int) {
	for c := cur; 2*c < h.pos; {
		b := 0
		if h.a[2*c] < h.a[2*c+1] {
			b = 2 * c
		} else {
			b = 2*c + 1
		}
		if h.a[b] < h.a[c] {
			h.a[c], h.a[b] = h.a[b], h.a[c]
			h.imap[h.vmap[c]], h.imap[h.vmap[b]] = h.imap[h.vmap[b]], h.imap[h.vmap[c]]
			h.vmap[c], h.vmap[b] = h.vmap[b], h.vmap[c]
			c = b
		} else {
			break
		}
	}
}
func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

const (
	//MaxScanTokenSize = 64 * 1024 // package default
	MaxScanTokenSize = 8 * 1024 * 1024 // 8M
)

func init() {
	scanner.Buffer(make([]byte, 0, MaxScanTokenSize), MaxScanTokenSize)
	scanner.Split(bufio.ScanWords)
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

type Edge struct {
	From int
	To   int
	Cap  int
	Flow int
}

type Graph struct {
	NNode  int
	NEdge  int
	Edges  []Edge
	Nodes  [][]int

	Colors []int
}

func NewGraph(nNode, nEdge int) *Graph {
	g := &Graph{
		NNode: nNode,
		NEdge: nEdge,
		Edges: make([]Edge, 0, nEdge),
		Nodes: make([][]int, nNode, nNode),

		Colors: make([]int, nNode, nNode),
	}
	return g
}

func (g *Graph) AddEdge(from, to, cap, flow int) {
	g.Nodes[from] = append(g.Nodes[from], len(g.Edges))
	g.Edges = append(g.Edges, Edge{from, to, cap, flow})
	g.Nodes[to] = append(g.Nodes[to], len(g.Edges))
	g.Edges = append(g.Edges, Edge{to, from, cap, flow})
}

func (g *Graph) Show() {
	fmt.Printf("n node = %d, n edge = %d\n", g.NNode, g.NEdge)
	for i, cur := range g.Nodes {
		fmt.Printf("[%d]", i)
		for _, next := range cur {
			fmt.Printf(" %d", g.Edges[next].To)
		}
		fmt.Println()
	}
}

func paint(g *Graph, pre, cur int) {
	color := 1
	for _, ie := range g.Nodes[cur] {
		next := g.Edges[ie].To
		if pre == next {
			continue
		}
		for (pre != -1 && color == g.Colors[pre]) || (color == g.Colors[cur]) {
			color++
		}
		g.Colors[next] = color
		color++

		if pre != next {
			paint(g, cur, next)
		}
	}
}

func main() {
	n := readInt()
	g := NewGraph(n, n - 1)

	for i := 1; i < n; i++ {
		from, to := readInt(), readInt()
		g.AddEdge(from - 1, to - 1, 0, 0)
	}
	//g.Show()

	g.Colors[0] = 1
	paint(g, -1, 0)

	maxColor := 0
	for _, color := range g.Colors {
		if color > maxColor {
			maxColor = color
		}
	}

	w := bufio.NewWriter(os.Stdout)

	fmt.Fprintln(w, maxColor)
	//fmt.Println(maxColor)
	for i := 0; i < n; i++ {
		fmt.Fprintf(w, "%d ", g.Colors[i])
		//fmt.Printf("%d ", g.Colors[i])
	}
	fmt.Fprintln(w)
	//fmt.Println("")
	w.Flush()
}

package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

const (
	//MaxScanTokenSize = 64 * 1024 // package default
	MaxScanTokenSize = 8 * 1024 * 1024 // 8M
)

func init() {
	scanner.Buffer(make([]byte, 0, MaxScanTokenSize), MaxScanTokenSize)
	scanner.Split(bufio.ScanWords)
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

type Edge struct {
	From int
	To   int
	Cap  int
	Flow int
}

type Graph struct {
	NNode  int
	NEdge  int
	Edges  []Edge
	Nodes  [][]int

	Colors []int
}

func NewGraph(nNode, nEdge int) *Graph {
	g := &Graph{
		NNode: nNode,
		NEdge: nEdge,
		Edges: make([]Edge, 0, nEdge),
		Nodes: make([][]int, nNode, nNode),

		Colors: make([]int, nNode, nNode),
	}
	return g
}

func (g *Graph) AddEdge(from, to, cap, flow int) {
	g.Nodes[from] = append(g.Nodes[from], len(g.Edges))
	g.Edges = append(g.Edges, Edge{from, to, cap, flow})
	g.Nodes[to] = append(g.Nodes[to], len(g.Edges))
	g.Edges = append(g.Edges, Edge{to, from, cap, flow})
}

func (g *Graph) Show() {
	fmt.Printf("n node = %d, n edge = %d\n", g.NNode, g.NEdge)
	for i, cur := range g.Nodes {
		fmt.Printf("[%d]", i)
		for _, next := range cur {
			fmt.Printf(" %d", g.Edges[next].To)
		}
		fmt.Println()
	}
}

func paint(g *Graph, pre, cur int) {
	color := 1
	for _, ie := range g.Nodes[cur] {
		next := g.Edges[ie].To
		if pre == next {
			continue
		}
		for (pre != -1 && color == g.Colors[pre]) || (color == g.Colors[cur]) {
			color++
		}
		g.Colors[next] = color
		color++

		if pre != next {
			paint(g, cur, next)
		}
	}
}

func main() {
	n := readInt()
	g := NewGraph(n, n - 1)

	for i := 1; i < n; i++ {
		from, to := readInt(), readInt()
		g.AddEdge(from - 1, to - 1, 0, 0)
	}
	//g.Show()

	g.Colors[0] = 1
	paint(g, -1, 0)

	maxColor := 0
	for _, color := range g.Colors {
		if color > maxColor {
			maxColor = color
		}
	}

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	fmt.Fprintln(w, maxColor)
	for i := 0; i < n; i++ {
		fmt.Fprintf(w, "%d ", g.Colors[i])
	}
	fmt.Fprintln(w)
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"math"
	"os"
	"strconv"
)

var res []int

type Vertex struct {
	color int
	adj   []*Vertex
}

func (v *Vertex) add(u *Vertex) {
	v.adj = append(v.adj, u)
}

func (v *Vertex) dfs(us int, skip int) {
	v.color = us
	nxt := 0
	for nxt == us || nxt == skip {
		nxt++
	}
	for _, next := range v.adj {
		if next.color == 0 {
			next.dfs(nxt, us)
			nxt++
			for nxt == us || nxt == skip {
				nxt++
			}
		}
	}
}

func solve() {
	n := readInt()
	vertexes := make([]*Vertex, n)
	for i := 0; i < n; i++ {
		vertexes[i] = &Vertex{0, make([]*Vertex, 0)}
	}
	for i := 0; i < n-1; i++ {
		x := readInt() - 1
		y := readInt() - 1
		vertexes[y].add(vertexes[x])
		vertexes[x].add(vertexes[y])
	}
	vertexes[0].dfs(1, 0)
	max := 0
	for _, v := range vertexes {
		if max < len(v.adj)+1 {
			max = len(v.adj) + 1
		}
	}
	fmt.Println(max)
	var buffer bytes.Buffer
	for i, v := range vertexes {
		if i > 0 {
			buffer.WriteString(" ")
		}
		buffer.WriteString(strconv.Itoa(v.color))
	}
	fmt.Println(buffer.String())
}

var scanner *bufio.Scanner

type MinHeap struct {
	a    []int
	vmap []int
	imap []int
	n    int
	pos  int
}

const INF = math.MaxInt32

func NewMinHeap(m int) *MinHeap {
	heap := &MinHeap{}
	m += 2
	heap.n = m
	heap.a = make([]int, heap.n)
	heap.vmap = make([]int, heap.n)
	heap.imap = make([]int, heap.n)
	heap.pos = 1
	for i := 0; i < heap.n; i++ {
		heap.a[i] = INF
		heap.vmap[i] = -1
		heap.imap[i] = -1
	}
	return heap
}

func (h *MinHeap) Add(ind, x int) int {
	ret := h.imap[ind]
	if h.imap[ind] < 0 {
		h.a[h.pos] = x
		h.vmap[h.pos] = ind
		h.imap[ind] = h.pos
		h.pos++
		h.up(h.pos - 1)
	}
	if ret != -1 {
		return h.a[ret]
	}
	return x
}

func (h *MinHeap) Update(ind, x int) int {
	ret := h.imap[ind]
	if h.imap[ind] < 0 {
		h.a[h.pos] = x
		h.vmap[h.pos] = ind
		h.imap[ind] = h.pos
		h.pos++
		h.up(h.pos - 1)
	} else {
		h.a[ret] = x
		h.up(ret)
		h.down(ret)
	}
	return x
}

func (h *MinHeap) Remove(ind int) int {
	if h.pos == 1 {
		return INF
	}
	if h.imap[ind] == -1 {
		return INF
	}

	h.pos--
	rem := h.imap[ind]
	ret := h.a[rem]
	h.vmap[rem] = h.vmap[h.pos]
	h.imap[h.vmap[h.pos]] = rem
	h.imap[ind] = -1
	h.a[rem] = h.a[h.pos]
	h.a[h.pos] = INF
	h.vmap[h.pos] = -1

	h.up(rem)
	h.down(rem)
	return ret
}

func (h *MinHeap) Min() int {
	return h.a[1]
}

func (h *MinHeap) ArgMin() int {
	return h.vmap[1]
}

func (h *MinHeap) Size() int {
	return h.pos - 1
}

func (h *MinHeap) up(cur int) {
	for c, p := cur, cur>>1; p >= 1 && h.a[p] > h.a[c]; c, p = c>>1, p>>1 {
		h.a[p], h.a[c] = h.a[c], h.a[p]
		h.imap[h.vmap[p]], h.imap[h.vmap[c]] = h.imap[h.vmap[c]], h.imap[h.vmap[p]]
		h.vmap[p], h.vmap[c] = h.vmap[c], h.vmap[p]
	}
}

func (h *MinHeap) down(cur int) {
	for c := cur; 2*c < h.pos; {
		b := 0
		if h.a[2*c] < h.a[2*c+1] {
			b = 2 * c
		} else {
			b = 2*c + 1
		}
		if h.a[b] < h.a[c] {
			h.a[c], h.a[b] = h.a[b], h.a[c]
			h.imap[h.vmap[c]], h.imap[h.vmap[b]] = h.imap[h.vmap[b]], h.imap[h.vmap[c]]
			h.vmap[c], h.vmap[b] = h.vmap[b], h.vmap[c]
			c = b
		} else {
			break
		}
	}
}
func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"strconv"
)

var res []int

func solve() {
	n := readInt()
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, 0)
	}
	res = make([]int, n)
	for i := 0; i < n-1; i++ {
		x := readInt() - 1
		y := readInt() - 1
		g[y] = append(g[y], x)
		g[x] = append(g[x], y)
	}
	colors := make([]bool, n)
	q := make([]int, 1)
	time := make([]int, 1)
	q[0] = 0
	time[0] = 1
	for i := 0; i < len(q); i++ {
		c := q[i]
		curTime := time[i]
		for j := len(time) - 1; j >= 0; j-- {
			if curTime-time[j] >= 3 {
				cl := res[q[j]] - 1
				if !colors[cl] {
					break
				}
				colors[cl] = false
			}
		}
		for i := 0; i < len(colors); i++ {
			if !colors[i] {
				res[c] = i + 1
				colors[i] = true
				break
			}
		}
		for i := 0; i < len(g[c]); i++ {
			next := g[c][i]
			if res[next] == 0 {
				q = append(q, next)
				time = append(time, curTime+1)
			}
		}
	}
	max := 0
	for i := 0; i < len(res); i++ {
		if max < res[i] {
			max = res[i]
		}
	}
	var buffer bytes.Buffer
	for i := 0; i < len(res); i++ {
		if i > 0 {
			buffer.WriteString(" ")
		}
		buffer.WriteString(strconv.Itoa(res[i]))
	}
	fmt.Println(max)
	fmt.Println(buffer.String())
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"strconv"
)

var res []int

func solve() {
	n := readInt()
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, 0)
	}
	res = make([]int, n)
	for i := 0; i < n-1; i++ {
		x := readInt() - 1
		y := readInt() - 1
		g[y] = append(g[y], x)
		g[x] = append(g[x], y)
	}
	colors := make([]int, n)
	q := make([]int, 1)
	time := make([]int, 1)
	q[0] = 0
	time[0] = 1
	for i := 0; i < n; i++ {
		colors[i] = -100
	}
	for i := 0; i < len(q); i++ {
		c := q[i]
		curTime := time[i]
		for j := 0; j < len(colors); j++ {
			if colors[j]+3 <= curTime {
				res[c] = j + 1
				colors[j] = curTime
				break
			}
		}
		for j := 0; j < len(g[c]); j++ {
			next := g[c][j]
			if res[next] == 0 {
				q = append(q, next)
				time = append(time, curTime+1)
			}
		}
	}
	max := 0
	for i := 0; i < len(res); i++ {
		if max < res[i] {
			max = res[i]
		}
	}
	var buffer bytes.Buffer
	for i := 0; i < len(res); i++ {
		if i > 0 {
			buffer.WriteString(" ")
		}
		buffer.WriteString(strconv.Itoa(res[i]))
	}
	fmt.Println(max)
	fmt.Println(buffer.String())
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"strconv"
)

var res []int

func solve() {
	n := readInt()
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, 0)
	}
	res = make([]int, n)
	for i := 0; i < n-1; i++ {
		x := readInt() - 1
		y := readInt() - 1
		g[y] = append(g[y], x)
		g[x] = append(g[x], y)
	}
	colors := make([]int, n)
	q := make([]int, 1)
	time := make([]int, 1)
	q[0] = 0
	time[0] = 1
	for i := 0; i < n; i++ {
		colors[i] = -100
	}
	for i := 0; i < len(q); i++ {
		c := q[i]
		curTime := time[i]
		for i := 0; i < len(colors); i++ {
			if colors[i]+3 <= curTime {
				res[c] = i + 1
				colors[i] = curTime
				break
			}
		}
		for i := 0; i < len(g[c]); i++ {
			next := g[c][i]
			if res[next] == 0 {
				q = append(q, next)
				time = append(time, curTime+1)
			}
		}
	}
	max := 0
	for i := 0; i < len(res); i++ {
		if max < res[i] {
			max = res[i]
		}
	}
	var buffer bytes.Buffer
	for i := 0; i < len(res); i++ {
		if i > 0 {
			buffer.WriteString(" ")
		}
		buffer.WriteString(strconv.Itoa(res[i]))
	}
	fmt.Println(max)
	fmt.Println(buffer.String())
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"math"
	"os"
	"strconv"
)

var res []int

func solve() {
	n := readInt()
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, 0)
	}
	res = make([]int, n)
	for i := 0; i < n-1; i++ {
		x := readInt() - 1
		y := readInt() - 1
		g[y] = append(g[y], x)
		g[x] = append(g[x], y)
	}
	q := make([]int, 1)
	time := make([]int, 1)
	q[0] = 0
	time[0] = 1
	heap := NewMinHeap(n + 1)
	nextColor := 1
	for i := 0; i < len(q); i++ {
		curIndex := q[i]
		curTime := time[i]
		if heap.Size() == 0 || curTime < heap.Min() {
			heap.Add(nextColor, curTime)
			nextColor++
		}
		color := heap.ArgMin()
		res[curIndex] = color
		heap.Update(color, curTime+3)
		for j := 0; j < len(g[curIndex]); j++ {
			next := g[curIndex][j]
			if res[next] == 0 {
				q = append(q, next)
				time = append(time, curTime+1)
			}
		}
	}
	var buffer bytes.Buffer
	for i := 0; i < len(res); i++ {
		if i > 0 {
			buffer.WriteString(" ")
		}
		buffer.WriteString(strconv.Itoa(res[i]))
	}
	fmt.Println(nextColor - 1)
	fmt.Println(buffer.String())
}

var scanner *bufio.Scanner

type MinHeap struct {
	a    []int
	vmap []int
	imap []int
	n    int
	pos  int
}

const INF = math.MaxInt32

func NewMinHeap(m int) *MinHeap {
	heap := &MinHeap{}
	m += 2
	heap.n = m
	heap.a = make([]int, heap.n)
	heap.vmap = make([]int, heap.n)
	heap.imap = make([]int, heap.n)
	heap.pos = 1
	for i := 0; i < heap.n; i++ {
		heap.a[i] = INF
		heap.vmap[i] = -1
		heap.imap[i] = -1
	}
	return heap
}

func (h *MinHeap) Add(ind, x int) int {
	ret := h.imap[ind]
	if h.imap[ind] < 0 {
		h.a[h.pos] = x
		h.vmap[h.pos] = ind
		h.imap[ind] = h.pos
		h.pos++
		h.up(h.pos - 1)
	}
	if ret != -1 {
		return h.a[ret]
	}
	return x
}

func (h *MinHeap) Update(ind, x int) int {
	ret := h.imap[ind]
	if h.imap[ind] < 0 {
		h.a[h.pos] = x
		h.vmap[h.pos] = ind
		h.imap[ind] = h.pos
		h.pos++
		h.up(h.pos - 1)
	} else {
		h.a[ret] = x
		h.up(ret)
		h.down(ret)
	}
	return x
}

func (h *MinHeap) Remove(ind int) int {
	if h.pos == 1 {
		return INF
	}
	if h.imap[ind] == -1 {
		return INF
	}

	h.pos--
	rem := h.imap[ind]
	ret := h.a[rem]
	h.vmap[rem] = h.vmap[h.pos]
	h.imap[h.vmap[h.pos]] = rem
	h.imap[ind] = -1
	h.a[rem] = h.a[h.pos]
	h.a[h.pos] = INF
	h.vmap[h.pos] = -1

	h.up(rem)
	h.down(rem)
	return ret
}

func (h *MinHeap) Min() int {
	return h.a[1]
}

func (h *MinHeap) ArgMin() int {
	return h.vmap[1]
}

func (h *MinHeap) Size() int {
	return h.pos - 1
}

func (h *MinHeap) up(cur int) {
	for c, p := cur, cur>>1; p >= 1 && h.a[p] > h.a[c]; c, p = c>>1, p>>1 {
		h.a[p], h.a[c] = h.a[c], h.a[p]
		h.imap[h.vmap[p]], h.imap[h.vmap[c]] = h.imap[h.vmap[c]], h.imap[h.vmap[p]]
		h.vmap[p], h.vmap[c] = h.vmap[c], h.vmap[p]
	}
}

func (h *MinHeap) down(cur int) {
	for c := cur; 2*c < h.pos; {
		b := 0
		if h.a[2*c] < h.a[2*c+1] {
			b = 2 * c
		} else {
			b = 2*c + 1
		}
		if h.a[b] < h.a[c] {
			h.a[c], h.a[b] = h.a[b], h.a[c]
			h.imap[h.vmap[c]], h.imap[h.vmap[b]] = h.imap[h.vmap[b]], h.imap[h.vmap[c]]
			h.vmap[c], h.vmap[b] = h.vmap[b], h.vmap[c]
			c = b
		} else {
			break
		}
	}
}
func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

const (
	//MaxScanTokenSize = 64 * 1024 // package default
	MaxScanTokenSize = 8 * 1024 * 1024 // 8M
)

func init() {
	scanner.Buffer(make([]byte, 0, MaxScanTokenSize), MaxScanTokenSize)
	scanner.Split(bufio.ScanWords)
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

type Edge struct {
	From int
	To   int
	Cap  int
	Flow int
}

type Graph struct {
	NNode  int
	NEdge  int
	Edges  []Edge
	Nodes  [][]int

	Colors []int
}

func NewGraph(nNode, nEdge int) *Graph {
	g := &Graph{
		NNode: nNode,
		NEdge: nEdge,
		Edges: make([]Edge, 0, nEdge),
		Nodes: make([][]int, nNode, nNode),

		Colors: make([]int, nNode, nNode),
	}
	return g
}

func (g *Graph) AddEdge(from, to, cap, flow int) {
	g.Nodes[from] = append(g.Nodes[from], len(g.Edges))
	g.Edges = append(g.Edges, Edge{from, to, cap, flow})
	g.Nodes[to] = append(g.Nodes[to], len(g.Edges))
	g.Edges = append(g.Edges, Edge{to, from, cap, flow})
}

func (g *Graph) Show() {
	fmt.Printf("n node = %d, n edge = %d\n", g.NNode, g.NEdge)
	for i, cur := range g.Nodes {
		fmt.Printf("[%d]", i)
		for _, next := range cur {
			fmt.Printf(" %d", g.Edges[next].To)
		}
		fmt.Println()
	}
}

func paint(g *Graph, pre, cur int) {
	color := 1
	for _, ie := range g.Nodes[cur] {
		next := g.Edges[ie].To
		if pre == next {
			continue
		}
		if pre != -1 && color == g.Colors[pre] {
			color++
		}
		if color == g.Colors[cur] {
			color++
		}
		g.Colors[next] = color
		color++

		if pre != next {
			paint(g, cur, next)
		}
	}
}

func main() {
	n := readInt()
	g := NewGraph(n, n - 1)

	for i := 1; i < n; i++ {
		from, to := readInt(), readInt()
		g.AddEdge(from - 1, to - 1, 0, 0)
	}
	//g.Show()

	g.Colors[0] = 1
	paint(g, -1, 0)

	maxColor := 0
	for _, color := range g.Colors {
		if color > maxColor {
			maxColor = color
		}
	}
	fmt.Println(maxColor)
	for i := 0; i < n; i++ {
		fmt.Printf("%d ", g.Colors[i])
	}
	fmt.Println("")
}

package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

type Edge struct {
	From int
	To int
	Cap int
	Flow int
}

type Graph struct {
	NNode int
	NEdge int
	Edges []Edge
	Nodes [][]int

	Visited []bool
	Colors []int
}

func NewGraph(nNode, nEdge int) *Graph {
	g := &Graph{
		NNode: nNode,
		NEdge: nEdge,
		Edges: make([]Edge, 0, nEdge),
		Nodes: make([][]int, nNode, nNode),

		Visited: make([]bool, nNode, nNode),
		Colors: make([]int, nNode, nNode),
	}
	return g
}

func (g *Graph) AddEdge(from, to, cap, flow int) {
	g.Nodes[from] = append(g.Nodes[from], len(g.Edges))
	g.Edges = append(g.Edges, Edge{from, to, cap, flow})
	g.Nodes[to] = append(g.Nodes[to], len(g.Edges))
	g.Edges = append(g.Edges, Edge{to, from, cap, flow})
}

func (g *Graph) Show() {
	fmt.Printf("n node = %d, n edge = %d\n", g.NNode, g.NEdge)
	for i, cur := range g.Nodes {
		fmt.Printf("[%d]", i)
		for _, next := range cur {
			fmt.Printf(" %d", g.Edges[next].To)
		}
		fmt.Println()
	}
}

func paint(g *Graph, pre, cur int) {
	color := 1
	g.Visited[cur] = true
	for _, ie := range g.Nodes[cur] {
		next := g.Edges[ie].To
		if g.Visited[next] {
			continue
		}
		if pre != -1 && color == g.Colors[pre] {
			color++
		}
		if color == g.Colors[cur] {
			color++
		}
		g.Colors[next] = color
		color++
	}

	for _, ie := range g.Nodes[cur] {
		next := g.Edges[ie].To
		if !g.Visited[next] {
			paint(g, cur, next)
		}
	}
}

func main() {
	n := readInt()
	g := NewGraph(n, n - 1)

	for i := 1; i < n; i++ {
		from, to := readInt(), readInt()
		g.AddEdge(from - 1, to - 1, 0, 0)
	}
	//g.Show()

	g.Colors[0] = 1
	paint(g, -1, 0)

	maxColor := 0
	for _, color := range g.Colors {
		if color > maxColor {
			maxColor = color
		}
	}
	fmt.Println(maxColor)
	for i := 0; i < n; i++ {
		fmt.Printf("%d ", g.Colors[i])
	}
	fmt.Println("")
}

var scanner = bufio.NewScanner(os.Stdin)

const (
	//MaxScanTokenSize = 64 * 1024 // package default
	MaxScanTokenSize = 8 * 1024 * 1024 // 8M
)

func init() {
	scanner.Buffer(make([]byte, 0, MaxScanTokenSize), MaxScanTokenSize)
	scanner.Split(bufio.ScanWords)
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

const (
	//MaxScanTokenSize = 64 * 1024 // package default
	MaxScanTokenSize = 8 * 1024 * 1024 // 8M
)

func init() {
	scanner.Buffer(make([]byte, 0, MaxScanTokenSize), MaxScanTokenSize)
	scanner.Split(bufio.ScanWords)
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

type Edge struct {
	From int
	To   int
	Cap  int
	Flow int
}

type Graph struct {
	NNode  int
	NEdge  int
	Edges  []Edge
	Nodes  [][]int

	Colors []int
}

func NewGraph(nNode, nEdge int) *Graph {
	g := &Graph{
		NNode: nNode,
		NEdge: nEdge,
		Edges: make([]Edge, 0, nEdge),
		Nodes: make([][]int, nNode, nNode),

		Colors: make([]int, nNode, nNode),
	}
	return g
}

func (g *Graph) AddEdge(from, to, cap, flow int) {
	g.Nodes[from] = append(g.Nodes[from], len(g.Edges))
	g.Edges = append(g.Edges, Edge{from, to, cap, flow})
	g.Nodes[to] = append(g.Nodes[to], len(g.Edges))
	g.Edges = append(g.Edges, Edge{to, from, cap, flow})
}

func (g *Graph) Show() {
	fmt.Printf("n node = %d, n edge = %d\n", g.NNode, g.NEdge)
	for i, cur := range g.Nodes {
		fmt.Printf("[%d]", i)
		for _, next := range cur {
			fmt.Printf(" %d", g.Edges[next].To)
		}
		fmt.Println()
	}
}

func paint(g *Graph, pre, cur int) {
	color := 1
	for _, ie := range g.Nodes[cur] {
		next := g.Edges[ie].To
		if pre == next {
			continue
		}
		for (pre != -1 && color == g.Colors[pre]) || (color == g.Colors[cur]) {
			color++
		}
		g.Colors[next] = color
		color++

		if pre != next {
			paint(g, cur, next)
		}
	}
}

func main() {
	n := readInt()
	g := NewGraph(n, n - 1)

	for i := 1; i < n; i++ {
		from, to := readInt(), readInt()
		g.AddEdge(from - 1, to - 1, 0, 0)
	}
	//g.Show()

	g.Colors[0] = 1
	paint(g, -1, 0)

	maxColor := 0
	for _, color := range g.Colors {
		if color > maxColor {
			maxColor = color
		}
	}

	w := bufio.NewWriter(os.Stdout)
	//defer w.Flush()

	fmt.Fprintln(w, maxColor)
	for i := 0; i < n; i++ {
		fmt.Fprintf(w, "%d ", g.Colors[i])
	}
	fmt.Fprintln(w)
}