package main
import (
"bufio"
"os"
"strconv"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanWords)
scanInt := func() int {
scanner.Scan()
val, _ := strconv.Atoi(scanner.Text())
return val
}
if !scanner.Scan() {
return
}
n, _ := strconv.Atoi(scanner.Text())
m := scanInt()
colors := make([]int, n+1)
for i := 0; i < m; i++ {
a := scanInt()
b := scanInt()
c := scanInt()
if colors[a] != 0 {
colors[b] = (colors[a]%3) + 1
colors[c] = (colors[b]%3) + 1
} else if colors[b] != 0 {
colors[a] = (colors[b]%3) + 1
colors[c] = (colors[a]%3) + 1
} else if colors[c] != 0 {
colors[a] = (colors[c]%3) + 1
colors[b] = (colors[a]%3) + 1
} else {
colors[a] = 1
colors[b] = 2
colors[c] = 3
}
}
writer := bufio.NewWriter(os.Stdout)
for i := 1; i <= n; i++ {
writer.WriteString(strconv.Itoa(colors[i]))
if i < n {
writer.WriteByte(' ')
}
}
writer.WriteByte('\n')
writer.Flush()
}