package main

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

func main() {
	var n int
	fmt.Scanf("%d \n", &n)
	myMap := make(map[string]int)
	scanner := bufio.NewScanner(os.Stdin)
	for i := 0; i < n; i++ {
		scanner.Scan()
		temp := scanner.Text()
		if myMap[temp] == 0 {
			fmt.Println("OK")
		} else {
			result := temp + strconv.Itoa(myMap[temp])
			fmt.Println(result)
			myMap[result]++
		}
		myMap[temp]++
	}
}

package main
import (
  "fmt"
  "bufio"
  "os"
)

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

func main() {
  var n, i int
  var s string
  var dict map[string]int
  dict = make(map[string]int)
  fmt.Fscan(in, &n)
  for i=0; i<n; i++ {
    fmt.Fscan(in, &s)
    if (dict[s] == 0) {
      fmt.Println("OK")
      dict[s] = 1
    } else {
      fmt.Printf("%s%d\n", s, dict[s])
      dict[s] = dict[s] + 1
    }
  }
}

package main

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

func resp(db map[string]int, query string) string {
	asked_for, ok := db[query]
	if !ok {
		db[query] = 0
		return "OK"
	}
	asked_for += 1
	db[query] = asked_for
	query = query + strconv.Itoa(asked_for)
	db[query] = 0
	return query
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n int
	var query string
	fmt.Fscanln(reader, &n)
	db := make(map[string]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanln(reader, &query)
		fmt.Fprintln(writer, resp(db, query))
	}
}

package main

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

var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var n int
var s string

func main() {
	fmt.Fscan(reader, &n)
	m := make(map[string]int)
	for ; n != 0; n-- {
		fmt.Fscan(reader, &s)
		if m[s] == 0 {
			fmt.Println("OK")
		} else {
			fmt.Print(s, m[s], "\n")
		}
		m[s]++
	}
}

package main

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

var DEBUG = true

func main() {
	defer Flush()

	N := readi()
	m := make(map[string]bool)
	k := make(map[string]int)
	for i := 0; i < N; i++ {
		s := reads()
		if !m[s] {
			println("OK")
			m[s] = true
			k[s] = 1
			continue
		}
		printf("%s%d\n", s, k[s])
		k[s]++
	}

}

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func dbgf(f string, args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintf(os.Stderr, f, args...)
}

func dbg(args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

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

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minf(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

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

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxf(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func absf(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)
func main(){
	var n int
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n,_ = strconv.Atoi(scanner.Text())
	arrString := make([]string,n)
	for i:=0;i<n;i++{
		scanner.Scan()
		arrString[i] = scanner.Text()
	}
	read(arrString)
}

func read(dataArr []string){
	memory := map[string]int{}
	for _,data := range(dataArr){
		if memory[data] != 0{
			fmt.Printf("%s%d\n",data,memory[data])
		}else{
			fmt.Println("OK")
		}
		memory[data] += 1
	}
}

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
)

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	name := map[string]int{}
	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Fscanf(reader, "%s\n", &s)
		count, ok := name[s]
		if !ok {
			fmt.Printf("OK\n")
			name[s] = 0
		} else {
			fmt.Printf("%s%d\n", s, count+1)
			name[s] = count + 1
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	var n int
	fmt.Fscanf(in, "%d\n", &n)

	db := make(map[string]int, 0)

	for i := 0; i < n; i++ {
		var name string
		fmt.Fscanf(in, "%s\n", &name)

		count := db[name]
		db[name] = count + 1
		if count == 0 {
			fmt.Fprintln(out, "OK")
		} else {
			fmt.Fprintf(out, "%s%d\n", name, count)
		}
	}
	out.Flush()
}

package main

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

func main() {
	n := nextInt()
	m := make(map[string]int)
	for i := 0; i < n; i++ {
		x := nextWord()
		if next, ok := m[x]; ok {
			printf("%s%d\n", x, next)
			m[x] = next + 1
		} else {
			printf("OK\n")
			m[x] = 1
		}
		if i % 1000 == 0 {
			runtime.GC()
		}
	}
}

var lineScanner *bufio.Scanner
var wordScanner *bufio.Scanner

func init() {
	lineScanner = bufio.NewScanner(os.Stdin)
	wordScanner = bufio.NewScanner(strings.NewReader(""))
	wordScanner.Split(bufio.ScanWords)
}
func printf(format string, a ...interface{}) {
	fmt.Printf(format, a...)
}
func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

func nextWord() string {
	for !wordScanner.Scan() {
		if err := wordScanner.Err(); err != nil {
			panic(err)
		}
		line, err := nextLine()
		if err != nil {
			return ""
		}
		wordScanner = bufio.NewScanner(strings.NewReader(line))
		wordScanner.Split(bufio.ScanWords)
	}
	return wordScanner.Text()
}

func nextInt() int {
	res, err := strconv.Atoi(nextWord())
	if err != nil {
		panic(err)
	}
	return res
}

func nextInt64() int64 {
	res, err := strconv.ParseInt(nextWord(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func nextFloat64() float64 {
	res, err := strconv.ParseFloat(nextWord(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

package main

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

func main() {
	var nameCount int
	var name string
	names := make(map[string]int)
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscanf(reader, "%d\n", &nameCount)
	for i := 0; i < nameCount; i++ {
		fmt.Fscanf(reader, "%s\n", &name)
		if names[name] == 0 {
			fmt.Println("OK")
		} else {
			fmt.Printf("%v%v\n", name, names[name])
		}
		names[name]++
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	db := make(map[string]int)

	var n int
	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		for scanner.Scan() {
			if scanner.Text() != "" { break }
		}

		if db[scanner.Text()] != 0 {
			fmt.Fprintf(writer, "%v%v\n", scanner.Text(), db[scanner.Text()])
		} else {
			writer.WriteString("OK\n")
		}
		db[scanner.Text()]++
	}

	writer.Flush()
}

package main

import (
	"fmt"
	"bufio"
	"os"
	//"sort"
)

func main() {
	var n int
	var s string
	input := bufio.NewScanner(os.Stdin)
    	input.Split(bufio.ScanWords)
	fmt.Scan(&n)
	simpan:= make(map[string]int)
	for i:=0;i<n;i++ {
		input.Scan()
		s =input.Text()
		if simpan[s]==0 {
			fmt.Println("OK")
			simpan[s]=1
		} else{
			fmt.Printf("%s%d\n",s,simpan[s])
			simpan[s]+=1
		}
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	db := make(map[string]int)

	var n int
	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		for scanner.Scan() {
			if scanner.Text() != "" { break }
		}

		if db[scanner.Text()] != 0 {
			writer.WriteString(scanner.Text() + strconv.Itoa(db[scanner.Text()]) + "\n")
		} else {
			writer.WriteString("OK\n")
		}
		db[scanner.Text()]++
	}

	writer.Flush()
}

package main

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

func main() {
        m := make(map[string]int)
        var n int
        var s string
        r := bufio.NewReader(os.Stdin)
        fmt.Fscanf(r, "%d\n", &n)
        for i := 0; i < n; i++ {
                fmt.Fscanf(r, "%s\n", &s)
                v := m[s]
                if v == 0 {
                        fmt.Println("OK")
                } else {
                        fmt.Printf("%s%d\n", s, v)
                }
                v++
                m[s] = v
        }
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscanf(r, "%d\n", &n)
	ds := make(map[string]int, n)
	for i:= 0; i<n; i++{
		var s string
		fmt.Fscanf(r, "%s\n", &s)
		if _, ok := ds[s]; ok {
			ds[s]++
			fmt.Printf("%s%d\n", s, ds[s])
			continue
		}
		fmt.Println("OK")
		ds[s] = 0
	}
}

package main

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

var n int
var s string
var m = make(map[string]int)
var r = bufio.NewReader(os.Stdin)

func main() {
        fmt.Fscanf(r, "%d\n", &n)
        for i := 0; i < n; i++ {
                fmt.Fscanf(r, "%s\n", &s)
                v := m[s]
                if v == 0 {
                        fmt.Println("OK")
                } else {
                        fmt.Printf("%s%d\n", s, v)
                }
                v++
                m[s] = v
        }
}

package main

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

func main() {
	names := make(map[string]int)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	for scanner.Scan() {
		name := scanner.Text()
		v, ok := names[name]
		if ok == false {
			names[name] = 0
			fmt.Println("OK")
		}else {
			names[name] = v + 1
			fmt.Printf("%s%d\n", name, v + 1)
		}
	}
}

package main

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

func main() {
	names := make(map[string]int)

	reader := bufio.NewReader(os.Stdin)

	nStr, _, _ := reader.ReadLine()
	n, _ := strconv.ParseInt(string(nStr), 10, 64)

	for i := 0; i < int(n); i++ {
		nameBytes, _, _ := reader.ReadLine()
		name := string(nameBytes)

		if indices, ok := names[name]; ok {
			names[name]++
			fmt.Printf("%s%d\n", name, indices)
		} else {
			names[name] = 1
			fmt.Println("OK")
		}
	}
}

package main

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

func main() {
	var n int
	var nickname string
	r := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscanf(r,"%d\n", &n)
	database := make(map[string]int)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(r,"%s\n", &nickname)
		value := database[nickname]
		if value == 0 {
			fmt.Printf("%s\n", "OK")
		} else {
			fmt.Printf("%s%d\n", nickname, value)
		}
		database[nickname] = value + 1
	}
}

/*
%t: для вывода значений типа boolean (true или false)
%b: для вывода целых чисел в двоичной системе
%c: для вывода символов, представленных числовым кодом
%d: для вывода целых чисел в десятичной системе
%o: для вывода целых чисел в восьмеричной системе
%q: для вывода символов в одинарных кавычках
%x: для вывода целых чисел в шестнадцатиричной системе, буквенные символы числа имеют нижний регистр a-f
%X: для вывода целых чисел в шестнадцатиричной системе, буквенные символы числа имеют верхний регистр A-F
%U: для вывода символов в формате кодов Unicode, например, U+1234
%e: для вывода чисел с плавающей точкой в экспоненциальном представлении, например, -1.234456e+78
%E: для вывода чисел с плавающей точкой в экспоненциальном представлении, например, -1.234456E+78
%f: для вывода чисел с плавающей точкой, например, 123.456
%F: то же самое, что и %f
%g: для длинных чисел с плаващей точкой используется %e, для других - %f
%G: для длинных чисел с плаващей точкой используется %E, для других - %F
%s: для вывода строки
%p: для вывода значения указателя - адреса в шестнадцатеричном представлении
*/

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	dict := map[string]int {}
	for i := 0; i < n; i++ {
		scanner.Scan()
		name := scanner.Text()
		if val, ok := dict[name]; ok {
			fmt.Printf("%s\n", (name+strconv.Itoa(val)))
			dict[name] += 1
		} else {
			fmt.Printf("%s\n", "OK")
			dict[name] = 1
		}
	}
}

//	URL: http://codeforces.com/contest/4/problem/C
//	PROBLEM RESTATEMENT
//		Given a stream of strings.
//		If string has not been seen before, output "OK".
//		If string has been seen before, output name of string with occurrence.
//	APPROACH
//		Naive implementation problem. Just follow instructions.
//	NOTE
//		Scan is bad - too slow! Use bufio instead.

package main

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

func main() {
	var n int
	var name string
	reader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d\n", &n)
	m := make(map[string]int)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%s\n", &name)
		val := m[name]
		if val == 0 {
			fmt.Fprintf(writer, "OK\n")
		} else {
			fmt.Fprintf(writer, "%s%d\n", name, m[name])
		}
		m[name] += 1
	}
}

package main

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

func solve() {
	n := readInt()
	db := make(map[string]int)
	for i := 0; i < n; i++ {
		name := readString()

		v, exists := db[name]
		if exists {
			fmt.Print(name, v, "\n")
		} else {
			fmt.Println("OK")
			v = 0
		}
		db[name] = v + 1
	}
}

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()
}

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
}

package main

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

func main() {
	var n int
	fmt.Scanln(&n)
	scanner := bufio.NewScanner(os.Stdin)

	userList := make(map[string]int)
	for scanner.Scan() {
		username := scanner.Text()
		v, ok := userList[username]
		if ok {
			userList[username] += 1
			username = username + strconv.Itoa(v)
			userList[username] = 1
			fmt.Println(username)
		} else {
			userList[username] = 1
			fmt.Println("OK")
		}
	}
}

package main

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

func main() {
	var n int
	var name string

	// Faster Input
	in := bufio.NewReader(os.Stdin)

	db := make(map[string]int, 100005)

	//fmt.Scanf("%d", &n)
	fmt.Fscanf(in, "%d\n", &n)

	for i := 0; i < n; i++ {
		// Individual name
		fmt.Fscanln(in, &name)
		// Add it to the db
		//fmt.Println(name)

		count, exists := db[name]

		if !exists {
			//fmt.Println("Adding new")
			//db[name] = 0
			fmt.Println("OK")
		} else {
			//fmt.Println(name, "Found. Occurences: ", count)
			fmt.Printf("%s%d\n", name, count)
		}

		db[name]++
	}

	//fmt.Println(db)
}

package main

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

func main() {
	var n int
	var str string
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	t := sc.Text()
	n, _ = strconv.Atoi(t)
	userId := make(map[string]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		str = sc.Text()
		num, ok := userId[str]
		if ok {
			fmt.Printf("%s%d\n", str, num)
			userId[str] = num + 1
		} else {
			userId[str] = 1
			fmt.Println("OK")
		}
	}
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    writer := bufio.NewWriter(os.Stdout)
    var n int
    m := make(map[string]int)
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        for scanner.Scan() {
            if scanner.Text() != "" { break }
        }
        if m[scanner.Text()] == 0 {
            writer.WriteString("OK"+"\n")
            m[scanner.Text()]++
        } else {
            writer.WriteString(scanner.Text()+strconv.Itoa(m[scanner.Text()])+"\n")
            m[scanner.Text()]++
        }
    }
    writer.Flush()
}

// wa on test 4
package main

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

type IntIO struct {
	tmp []byte
}

func (s *IntIO) Flush() {
}

func (s *IntIO) Init() {
	s.tmp = make([]byte, 32, 32)
}

func main() {

	var (
		table   map[string]int32
		n, i, f int32
		str     string
		r       *bufio.Reader
		w       *bufio.Writer
	)

	r = bufio.NewReader(os.Stdin)
	w = bufio.NewWriter(os.Stdout)

	table = make(map[string]int32)
	fmt.Scan(&n)
	for i = 1; i <= n; i++ {
		fmt.Fscan(r, &str)
		f, _ = table[str]
		if 0 == f {
			fmt.Fprint(w, "OK\n")
		} else {
			fmt.Fprintf(w, "%s%d\n", str, f)
		}
		table[str]++
	}
	w.Flush()
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var count int
	fmt.Fscanf(r, "%d\n", &count)
	dic := make(map[string]int, count)
	for i := 0; i < count; i++ {
		var str string
		fmt.Fscanf(r, "%s\n", &str)
		if _, has := dic[str]; has {
			fmt.Printf("%s%d\n", str, dic[str])
			dic[str]++
		} else {
			dic[str] = 1
			fmt.Println("OK")
		}
	}
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func readline() string {
	name, err := reader.ReadString('\n')
	if err != nil {
		log.Fatal(err)
	}

	name = strings.TrimRight(name, "\r\n")

	return name
}

func flush() {
	err := writer.Flush()
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	defer flush()

	var n int
	scanf("%d\n", &n)

	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name := readline()
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			printf("%s%d\n", name, count)
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func close() {
	err := writer.Flush()
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	var n int
	scanf("%d\n", &n)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}

		name = strings.TrimRight(name, "\r\n")
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			fmt.Fprintf(writer, "%s%d\n", name, count)
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
	close()
}

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
)

type login struct {
	name  []byte
	count int
}

func bytesEqual(a, b []byte) bool {
	l := len(a)
	if l != len(b) {
		return false
	}
	for i := 0; i < l; i += 1 {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func updateLogins(list []login, l []byte) ([]login, int) {
	for i := 0; i < len(list); i += 1 {
		if bytesEqual(list[i].name, l) {
			list[i].count += 1
			return list, list[i].count
		}
	}
	list = append(list, login{name: l, count: 0})
	return list, 0
}

// https://codeforces.com/problemset/problem/4/C
// комментарии к решению
// Задача хорошо ложиться на go'шный map, но при попытке использования map[string]int
// мы падаем по времени, а для []byte map не работает, поэтому реализуем на основе списков
func taskSolution(a [][]byte) string {
	count := 0
	seen := []login{}
	ans := []byte{}
	for i := 0; i < len(a); i += 1 {
		line := bytes.TrimSpace(a[i])
		seen, count = updateLogins(seen, line)
		if count == 0 {
			ans = append(ans, []byte("OK")...)
		} else {
			intStr := fmt.Sprint(count)
			//contest failed w/o trim spaces
			cleanedNum := bytes.TrimSpace([]byte(intStr))
			ans = append(ans, line...)
			ans = append(ans, cleanedNum...)
		}
		ans = append(ans, byte('\n'))
	}
	return string(ans)
}

func main() {
	var n int
	if _, err := fmt.Scan(&n); err != nil {
		panic(err)
	}

	inRaw, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}
	inRawArr := bytes.Split(bytes.TrimSpace(inRaw), []byte("\n"))

	fmt.Println(taskSolution(inRawArr))
}

package main

import (
	"fmt"
	"io/ioutil"
	"os"
)

type line struct {
	start int
	end   int
}

// https://codeforces.com/problemset/problem/4/C
// комментарии к решению
// При попытке считывания string через fmt.Scan мы падаем по времени, поэтому
// парсим входные данные самостоятельно, приводя строки к string только в крайнем случае
func taskSolution(in []byte) string {
	names := map[string]int{}
	ans := []byte{}
	next := line{start: 0, end: 0}
	// iterate lines
	for next.end < len(in) {
		next.start = next.end
		// skip spaces
		for next.start < len(in) && !(in[next.start] >= 'a' && in[next.start] <= 'z') {
			next.start += 1
		}
		// find end of word
		next.end = next.start
		for next.end < len(in) && in[next.end] >= 'a' && in[next.end] <= 'z' {
			next.end += 1
		}
		// break at EOF
		if next.end == len(in) {
			break
		}
		// check logins
		loginStr := string(in[next.start:next.end])
		if _, ok := names[loginStr]; ok {
			ans = append(ans, []byte(fmt.Sprintf("%s%d", loginStr, names[loginStr]))...)
			names[loginStr] += 1
		} else {
			ans = append(ans, []byte("OK")...)
			names[loginStr] = 1
		}
		ans = append(ans, byte('\n'))
	}
	return string(ans)
}

func main() {
	var n int
	if _, err := fmt.Scan(&n); err != nil {
		panic(err)
	}

	inRaw, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}

	fmt.Println(taskSolution(inRaw))
}

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
)

type login struct {
	name  []byte
	count int
}

func bytesEqual(a, b []byte) bool {
	l := len(a)
	if l != len(b) {
		return false
	}
	for i := 0; i < l; i += 1 {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func updateLogins(list []login, l []byte) ([]login, int) {
	for i := 0; i < len(list); i += 1 {
		if bytesEqual(list[i].name, l) {
			list[i].count += 1
			return list, list[i].count
		}
	}
	list = append(list, login{name: l, count: 0})
	return list, 0
}

// https://codeforces.com/problemset/problem/4/C
// комментарии к решению
// Задача хорошо ложиться на go'шный map, но при попытке использования map[string]int
// мы падаем по времени, а для []byte map не работает, поэтому реализуем на основе списков
func taskSolution(a [][]byte) string {
	count := 0
	seen := []login{}
	ans := []byte{}
	for i := 0; i < len(a); i += 1 {
		line := bytes.TrimSpace(a[i])
		seen, count = updateLogins(seen, line)
		if count == 0 {
			ans = append(ans, []byte("OK")...)
		} else {
			intStr := fmt.Sprint(count)
			//contest failed w/o trim spaces
			//cleanedNum := bytes.TrimSpace([]byte(intStr))
			ans = append(ans, line...)
			//ans = append(ans, cleanedNum...)
			ans = append(ans, intStr...)
		}
		ans = append(ans, byte('\n'))
	}
	return string(ans)
}

func main() {
	var n int
	if _, err := fmt.Scan(&n); err != nil {
		panic(err)
	}

	inRaw, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}
	inRawArr := bytes.Split(bytes.TrimSpace(inRaw), []byte("\n"))

	fmt.Println(taskSolution(inRawArr))
}

package main

import (
	"fmt"
	"io/ioutil"
	"os"
)

type line struct {
	start int
	end   int
}

// https://codeforces.com/problemset/problem/4/C
// комментарии к решению
// Задача хорошо ложиться на go'шный map, но при попытке использования map[string]int
// мы падаем по времени, а для []byte map не работает, поэтому реализуем на основе списков
func taskSolution(in []byte) string {
	names := map[string]int{}
	ans := []byte{}
	next := line{start: 0, end: 0}
	// iterate lines
	for next.end < len(in) {
		next.start = next.end
		// skip spaces
		for next.start < len(in) && !(in[next.start] >= 'a' && in[next.start] <= 'z') {
			next.start += 1
		}

		// find end of word
		next.end = next.start
		for next.end < len(in) && in[next.end] >= 'a' && in[next.end] <= 'z' {
			next.end += 1
		}
		if next.end == len(in) {
			break
		}

		// check
		loginStr := string(in[next.start:next.end])
		if _, ok := names[loginStr]; ok {
			ans = append(ans, []byte(fmt.Sprintf("%s%d", loginStr, names[loginStr]))...)
			names[loginStr] += 1
		} else {
			ans = append(ans, []byte("OK")...)
			names[loginStr] = 1
		}
		ans = append(ans, byte('\n'))
	}
	return string(ans)
}

func main() {
	var n int
	if _, err := fmt.Scan(&n); err != nil {
		panic(err)
	}

	inRaw, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}

	fmt.Println(taskSolution(inRaw))
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var n int
	scanner.Scan()
	t := scanner.Text()
	n, _ = strconv.Atoi(t)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		scanner.Scan()
		name := scanner.Text()
		if val, ok := names[name]; ok {
			names[name] = val + 1
			fmt.Println(name + strconv.Itoa(val))
		} else {
			names[name] = 1
			fmt.Println("OK")
		}
	}
}

package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"strconv"
	"strings"
	"text/scanner"
)

func check(e error) {
	if e != nil {
		panic(e)
	}
}

func main() {
	var n int // first input to the problem
	var counters map[string]int // keep track of entries
	counters = make(map[string]int)

	dat, err := ioutil.ReadAll(os.Stdin)
	check(err)
	var str_data string = string(dat);

	reader := strings.NewReader(str_data)

	var scn scanner.Scanner
	scn.Init(reader)

    scn.Scan()
	var text string = scn.TokenText();

	n, err = strconv.Atoi(text)
	check(err)

	var i int
	for i = 0; i < n; i++ {
		scn.Scan()
		var name string = scn.TokenText();
		check(err)

		// does name exist already?
		val, ok := counters[name]
		if ok == true {
			val++;
			var output string = name + strconv.Itoa(val)
			fmt.Println(output)
			counters[name] = val
		} else {
			fmt.Println("OK")
			counters[name] = 0
		}
	}
}

package main

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

type Acc struct {
	users map[string]int
}

func (a *Acc) Set(name string) {
	if _, ok := a.users[name]; ok {
		a.users[name]++
		fmt.Println(name + strconv.Itoa(a.users[name]))
	} else {
		a.users[name] = 0
		fmt.Println("OK")
	}

}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)
	i, v := 0, 0
	var acc Acc
	acc.users = make(map[string]int)

	for sc.Scan() {
		i++
		if i == 1 {
			v, _ = strconv.Atoi(sc.Text())
			continue
		}
		if v+2 == i {
			return
		}
		acc.Set(sc.Text())
	}
}

package main

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

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

	var userCount int

	if scanner.Scan() {
		line := scanner.Text()
		fmt.Sscanf(line, "%d", &userCount)
	}

	db := make(map[string]int)
	for i := 0; i < userCount && scanner.Scan(); i++ {
		line := scanner.Text()
		count, exist := db[line]
		if !exist {
			fmt.Println("OK")
		} else {
			fmt.Println(line + strconv.Itoa(count))
		}
		db[line] += 1
	}
}

package main

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

func djb2(s string) uint {
	h := uint(5381)
	for i, l := 0, len(s); i < l; i++ {
		h = (h << 5) + h + uint(s[i])
	}
	return h
}

type hash_value struct {
	str string
	count int
	used bool
}

type hash_table struct {
	table []hash_value
}

func newHashTable(m int) *hash_table {
	return &hash_table{make([]hash_value, m)}
}

func (h *hash_table) get(s string) *hash_value {
	hash := djb2(s)
	idx := hash % magic_m

	n := &h.table[idx]
	for n.used {
		if n.str == s {
			return n
		} else {
			if idx == 0 {
				idx = magic_m - 1
			} else {
				idx -= 1
			}
			n = &h.table[idx]
		}
	}
	n.str = s
	n.used = true
	return n
}

// a prime greater than our known "max" value - 100000
const magic_m = 100003

func main() {
	var n int
	var s string

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

	fmt.Fscanf(in, "%d\n", &n)
	h := newHashTable(magic_m)

	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%s\n", &s)

		v := h.get(s)
		if v.count == 0 {
			fmt.Fprintf(out, "OK\n")
		} else {
			fmt.Fprintf(out, "%s%d\n", s, v.count)
		}
		v.count += 1
	}
}

package main

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

func main() {
	var n int
	var s string

	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()

	fmt.Fscanf(in, "%d\n", &n)

	h := make(map[string]int)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%s\n", &s)

		val := h[s]
		if val == 0 {
			fmt.Fprintf(out, "OK\n")
		} else {
			fmt.Fprintf(out, "%s%d\n", s, val)
		}
		h[s] = val + 1
	}
}

// https://codeforces.com/contest/4/problem/C
package main

import (
	"fmt"
	"strconv"
	"runtime/debug"
	"bufio"
	"os"
)

type Users map[string]*User
type User struct {
	Max int64
}

func main() {
	debug.SetGCPercent(-1)

	var newUserCount = 0
	_, err := fmt.Scanf("%d\n", &newUserCount)
	if err != nil {
		panic(err)
	}

	reader := bufio.NewReader(os.Stdin)
	db := make(Users, newUserCount)
	for i := 0; i < newUserCount; i++ {
		userNameBytes, _, err := reader.ReadLine()
		if err != nil {
			panic(err)
		}
		userName := string(userNameBytes)

		user, ok := db[userName]
		if !ok {
			db[userName] = &User{}
			fmt.Println("OK")
			continue
		}

		user.Max++
		newUserName := userName + strconv.FormatInt(user.Max, 10)
		db[newUserName] = &User{}
		fmt.Println(newUserName)
	}

	return
}

package main

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

func main() {
	var n int
	var s string

	r := bufio.NewReader(os.Stdin)

	fmt.Fscanf(r, "%d\n", &n)

	h := make(map[string]int)
	for i := 0; i < n; i++ {
		fmt.Fscanf(r, "%s\n", &s)

		val := h[s]
		if val == 0 {
			fmt.Printf("OK\n")
		} else {
			fmt.Printf("%s%d\n", s, val)
		}
		h[s] = val + 1
	}
}

package main

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

func djb2(s string) uint {
	h := uint(5381)
	for i, l := 0, len(s); i < l; i++ {
		h = (h << 5) + h + uint(s[i])
	}
	return h
}

type hash_value struct {
	str string
	count int
	next *hash_value
}

type hash_table struct {
	table []*hash_value
}

func newHashTable(m int) *hash_table {
	return &hash_table{make([]*hash_value, m)}
}

func (h *hash_table) get(s string) *hash_value {
	hash := djb2(s)
	idx := hash % magic_m
	// fmt.Printf("%s -> %d -> %d\n", s, hash, idx)

	node := h.table[idx]
	if node == nil {
		v := &freelist[next_free_idx]
		next_free_idx += 1

		v.str = s
		h.table[idx] = v
		return v
	} else {
		for {
			if node.str == s {
				return node
			} else {
				if node.next != nil {
					node = node.next
				} else {
					v := &freelist[next_free_idx]
					next_free_idx += 1

					v.str = s
					node.next = v
					return v
				}
			}
		}
	}
}

// a prime greater than our known "max" value - 100000
const magic_m = 100003

var freelist []hash_value
var next_free_idx = 0

func main() {
	var n int
	var s string

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

	fmt.Fscanf(in, "%d\n", &n)
	h := newHashTable(magic_m)
	freelist = make([]hash_value, n)

	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%s\n", &s)

		v := h.get(s)
		// fmt.Printf("%v\n", v)
		if v.count == 0 {
			fmt.Fprintf(out, "OK\n")
		} else {
			fmt.Fprintf(out, "%s%d\n", s, v.count)
		}
		v.count += 1
	}
}

package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1024*1024)
	n, err := strconv.ParseInt(readLine(reader), 10, 0)
	checkError(err)

	m := make(map[string]int)
	for i := 0; i < int(n); i++ {
		s := readLine(reader)
		_, ok := m[s]
		if ok {
			m[s] += 1
			fmt.Printf("%v%v\n", s, m[s])
		} else {
			m[s] = 0
			fmt.Println("OK")
		}
	}
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

package main

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

func main() {
	var n int
	var s string
	mp := make(map[string]int)
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%s\n", &s)
		if mp[s] == 0 {
			fmt.Fprintf(out, "OK\n")
		} else {
			fmt.Fprintf(out, "%s%d\n", s, mp[s])
		}
		mp[s]++
	}
	out.Flush()
}

package main

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

func main() {
	var n int
	var s string
	mp := make(map[string]int)
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%s\n", &s)
		if mp[s] == 0 {
			fmt.Println("OK")
		} else {
			fmt.Printf("%v%v\n", s, mp[s])
		}
		mp[s]++
	}
}

package main

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

func main() {
	var n int
	var s string
	mp := make(map[string]int)
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%s\n", &s)
		if mp[s] == 0 {
			fmt.Fprintf(out, "OK\n")
		} else {
			fmt.Fprintf(out, "%s%d\n", s, mp[s])
		}
		mp[s]++
	}
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {

	defer writer.Flush()
	var t int
	scanf("%d\n", &t)

	db := make(map[string]*int)

	for i := 0; i < t; i++ {
		var name string
		scanf("%s \n", &name)

		names, ok := db[name]
		if !ok {
			var a = 0
			db[name] = &a
			printf("OK\n")
			continue
		}

		*names = *names + 1
		newName := name + strconv.Itoa(*names)
		printf("%s\n", newName)
	}
}

package main

import (
	"fmt"
)

func main() {
	name := map[string]int{}
	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scanf("%s\n", &s)
		count, ok := name[s]
		if !ok {
			fmt.Printf("OK\n")
			name[s] = 0
		} else {
			fmt.Printf("%s%d\n", s, count+1)
			name[s] = count + 1
		}
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	db := make(map[string]int)

	var n int
	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		scanner.Scan()

		if db[scanner.Text()] != 0 {
			fmt.Fprintf(writer, "%v%v\n", scanner.Text(), db[scanner.Text()])
		} else {
			writer.WriteString("OK\n")
		}
		db[scanner.Text()]++
	}

	writer.Flush()
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscanf(r, "%d\n", &n)
	ds := make(map[string]int, n)
	for i:= 0; i<n; i++{
		var s string
		fmt.Fscanf(r, "%d\n", &s)
		if _, ok := ds[s]; ok {
			ds[s]++
			fmt.Printf("%s%d\n", s, ds[s])
			continue
		}
		fmt.Println("OK")
		ds[s] = 0
	}
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var n int
	scanf("%d\n", &n)

	names := make(map[string]int)
	for i := 0; i < n; i++ {
		nameb, err := reader.ReadBytes('\n')
		if err != nil {
			log.Fatal(err)
		}

		name := string(nameb[0 : len(nameb)-1])
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			printf("%s%dx\n", name, count)
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}
func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	defer writer.Flush()

	var n int
	scanf("%d\n", &n)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}

		name = strings.TrimSuffix(name, "\n")
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			printf("%s%d\n", name, count)
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func close() {
	err := writer.Flush()
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	var n int
	scanf("%d\n", &n)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}

		name = strings.TrimSuffix(name, "\n")
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			printf("x%s%d\n", name, count)
			writer.Flush()
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
	close()
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

//func scanf(format string, args ...interface{}) {
//	_, err := fmt.Scanf(format, args...)
//	if err != nil {
//		fmt.Printf("%v\n", err)
//		log.Fatal(err)
//	}
//}

func main() {
	defer writer.Flush()

	var n int
	scanf("%d\n", &n)

	names := make(map[string]int)
	for i := 0; i < n; i++ {
		nameb, err := reader.ReadBytes('\n')
		if err != nil {
			log.Fatal(err)
		}

		name := string(nameb[0 : len(nameb)-1])
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			printf("%s%d\n", name, count)
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func close() {
	err := writer.Flush()
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	var n int
	scanf("%d\n", &n)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}

		name = strings.TrimSuffix(name, "\n")
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			printf("x%s%d\n", name, count)
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
	close()
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func close() {
	err := writer.Flush()
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	var n int
	scanf("%d\n", &n)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}

		name = strings.TrimSuffix(name, "\n")
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			for i := 0; i < len(name); i++ {
				fmt.Fprintf(writer, "[%d=%d,%c]", i, int(name[i]), name[i])
			}
			fmt.Fprintf(writer, "%s%d\n", name[0:7], count)
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
	close()
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}
func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	defer writer.Flush()

	var n int
	scanf("%d\n", &n)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}

		name = strings.TrimSuffix(name, "\n")
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			printf("%s%d\n", name, count*2)
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var n int
	scanf("%d\n", &n)

	names := make(map[string]int)
	for i := 0; i < n; i++ {
		nameb, err := reader.ReadBytes('\n')
		if err != nil {
			log.Fatal(err)
		}

		name := string(nameb[0 : len(nameb)-1])
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			printf("%s%d\n", name, count)
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func close() {
	err := writer.Flush()
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	var n int
	scanf("%d\n", &n)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}

		name = strings.TrimSuffix(name, "\n")
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			printf("%s%d\n", name, count)
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
	close()
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func close() {
	err := writer.Flush()
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	var n int
	scanf("%d\n", &n)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}

		name = strings.TrimSuffix(name, "\n")
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			//printf("%s%d\n", name, count)
			printf("%s", name)
			printf("%d", count)
			writer.Flush()
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
	close()
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func close() {
	err := writer.Flush()
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	var n int
	scanf("%d\n", &n)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}

		name = strings.TrimSuffix(name, "\n")
		if len(name) == 0 {
			continue
		}

		if _, ok := names[name]; ok {
			//printf("x%s%d\n", name, count)
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
	close()
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func close() {
	err := writer.Flush()
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	var n int
	scanf("%d\n", &n)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}

		name = strings.TrimSuffix(name, "\n")
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			fmt.Fprintf(writer, "%s%d\n", name[0:], count)
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
	close()
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func close() {
	err := writer.Flush()
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	var n int
	scanf("%d\n", &n)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name, err := reader.ReadString('\n')
		for i := 0; i < len(name); i++ {
			fmt.Fprintf(writer, "[%d=%d,%c]", i, int(name[i]), name[i])
		}
		if err != nil {
			log.Fatal(err)
		}

		name = strings.TrimSuffix(name, "\n")
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			for i := 0; i < len(name); i++ {
				fmt.Fprintf(writer, "[%d=%d,%c]", i, int(name[i]), name[i])
			}
			fmt.Fprintf(writer, "%s%d\n", name[0:7], count)
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
	close()
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}
func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	defer writer.Flush()

	var n int
	scanf("%d\n", &n)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}

		name = strings.TrimSuffix(name, "\n")
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			fmt.Printf("%s%d\n", name, count)
			names[name]++
		} else {
			fmt.Printf("OK\n")
			names[name] = 1
		}
	}
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func close() {
	err := writer.Flush()
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	var n int
	scanf("%d\n", &n)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}

		name = strings.TrimSuffix(name, "\n")
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			fmt.Fprintf(writer, "%s%d\n", name[0:len(name)], count)
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
	close()
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func close() {
	err := writer.Flush()
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	var n int
	scanf("%d\n", &n)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}

		name = strings.TrimSuffix(name, "\n")
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			fmt.Fprintf(writer, "%s%d\n", name, count)
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
	close()
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func close() {
	err := writer.Flush()
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	var n int
	scanf("%d\n", &n)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}

		name = strings.TrimSuffix(name, "\n")
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			printf("%s%d\n", name, count)
			writer.Flush()
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
	close()
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func close() {
	err := writer.Flush()
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	var n int
	scanf("%d\n", &n)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}

		name = strings.TrimSuffix(name, "\n")
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			fmt.Fprintf(writer, "%s%d\n", name[0:6], count)
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
	close()
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) {
	_, err := fmt.Fprintf(writer, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func scanf(f string, a ...interface{}) {
	_, err := fmt.Fscanf(reader, f, a...)
	if err != nil {
		log.Fatal(err)
	}
}

func close() {
	err := writer.Flush()
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	var n int
	scanf("%d\n", &n)
	names := make(map[string]int)
	for i := 0; i < n; i++ {
		name, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}

		name = strings.TrimSuffix(name, "\n")
		if len(name) == 0 {
			continue
		}

		if count, ok := names[name]; ok {
			fmt.Fprintf(writer, "%s%d\n", name[0:2], count)
			names[name]++
		} else {
			printf("OK\n")
			names[name] = 1
		}
	}
	close()
}

package main

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

func main() {
	var n int
	fmt.Scanf("%d \n", &n)
	result := ""
	myMap := make(map[string]int)
	scanner := bufio.NewScanner(os.Stdin)
	for i := 0; i < n; i++ {
		scanner.Scan()
		temp := scanner.Text()
		if myMap[temp] == 0 {
			fmt.Println("OK")
		} else {
			result += temp + strconv.Itoa(myMap[temp])
			fmt.Println(result)
			myMap[result]++
		}
		myMap[temp]++
	}
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    var n int
    m := make(map[string]int)
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        scanner.Scan()
        if m[scanner.Text()] == 0 {
            fmt.Println("OK")
            m[scanner.Text()]++
        } else {
            fmt.Println(scanner.Text()+strconv.Itoa(m[scanner.Text()]))
            m[scanner.Text()]++
        }
    }
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    writer := bufio.NewWriter(os.Stdout)
    var n int
    m := make(map[string]int)
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        scanner.Scan()
        if m[scanner.Text()] == 0 {
            writer.WriteString("OK"+"\n")
            m[scanner.Text()]++
        } else {
            writer.WriteString(scanner.Text()+strconv.Itoa(m[scanner.Text()])+"\n")
            m[scanner.Text()]++
        }
    }
    writer.Flush()
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {

	defer writer.Flush()
	var t int
	scanf("%d\n", &t)

	db := make(map[string]*int)

	for i := 0; i < t; i++ {
		var name string
		scanf("%s \n", &name)

		names, ok := db[name]
		if !ok {
			var a = 0
			db[name] = &a
			fmt.Println("OK")
			continue
		}

		*names = *names + 1
		newName := name + strconv.Itoa(*names)
		printf("%s\n", newName)
	}
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {

	defer writer.Flush()
	var t int
	scanf("%d\n", &t)

	db := make(map[string]*int)

	for i := 0; i < t; i++ {
		var name string
		scanf("%s \n", &name)

		names, ok := db[name]
		if !ok {
			var a = 0
			db[name] = &a
			fmt.Println("OK")
			continue
		}

		*names = *names + 1
		newName := name + strconv.Itoa(*names)
		println(newName)
	}
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
	var t int
	scanf("%d\n", &t)

	db := make(map[string]*int)

	for i := 0; i < t; i++ {
		var name string
		scanf("%s \n", &name)

		names, ok := db[name]
		if !ok {
			var a = 0
			db[name] = &a
			fmt.Println("OK")
			writer.Flush()
			continue
		}

		*names = *names + 1
		newName := name + strconv.Itoa(*names)
		println(newName)

		writer.Flush()
	}
}

package main

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

func main() {
	var t int
	fmt.Scanf("%d\n", &t)

	db := make(map[string]*int)

	reader := bufio.NewReader(os.Stdin)

	for i := 0; i < t; i++ {
		//var name string
		//fmt.Scanf("%s \n", &name)
		name, _ := reader.ReadString('\n')

		name = strings.Replace(name, "\n", "", -1)

		names, ok := db[name]
		if !ok {
			var a = 0
			db[name] = &a
			fmt.Println("OK")
			continue
		}

		*names = *names + 1
		newName := name + strconv.Itoa(*names)
		fmt.Println(newName)
	}
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {

	defer writer.Flush()
	var t int
	scanf("%d\n", &t)

	db := make(map[string]*int)

	for i := 0; i < t; i++ {
		var name string
		scanf("%s \n", &name)

		names, ok := db[name]
		if !ok {
			var a = 0
			db[name] = &a
			fmt.Println("OK")
			continue
		}

		*names = *names + 1
		newName := name + strconv.Itoa(*names)
		printf(newName)
	}
}

package main

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

var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var n int
var s string

func main() {
	fmt.Fscan(reader, &n)
	m := make(map[string]int)
	for ; n != 0; n-- {
		fmt.Fscan(reader, &s)
		if m[s] == 0 {
			fmt.Println("OK")
		} else {
			fmt.Print(s, m[s], "\n")
		}
		m[s]++
	}
	fmt.Println(n)
}

package main

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

func main() {
        m := make(map[string]int)
        var n int
        var s string
        r := bufio.NewReader(os.Stdin)
        fmt.Fscanf(r, "%d\n", &n)
        for i := 0; i < n; i++ {
                fmt.Scan(&s)//fmt.Fscanf(r, "%s\n", &s)
                v := m[s]
                if v == 0 {
                        fmt.Println("OK")
                } else {
                        fmt.Printf("%s%d\n", s, v)
                }
                v++
                m[s] = v
        }
}

package main

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

func main() {
        m := make(map[string]int)
        var n int
        r := bufio.NewReader(os.Stdin)
        fmt.Fscanf(r, "%d\n", &n)
        for i := 0; i < n; i++ {
                var s string
                fmt.Scan(&s)//fmt.Fscanf(r, "%s\n", &s)
                v := m[s]
                if v == 0 {
                        fmt.Println("OK")
                } else {
                        fmt.Printf("%s%d\n", s, v)
                }
                v++
                m[s] = v
        }
}

package main

import "fmt"

func main() {
	names := make(map[string]int)

	var n int
	fmt.Scanf("%d", &n)

	for i := 0; i < int(n); i++ {
		var name string
		fmt.Scanf("%s", &name)

		if indices, ok := names[name]; ok {
			names[name]++
			fmt.Printf("%s%d\n", name, indices)
		} else {
			names[name] = 1
			fmt.Println("OK")
		}
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	var dict StringSet
	for i := 0; i < n; i++ {
		scanner.Scan()
		name := scanner.Text()
		if(!dict.Has(name)) {
			dict.Add(name)
			fmt.Printf("%s\n", "OK")
		} else {
			fmt.Printf("%s\n", findNextAvailable(&dict, name))
		}
	}
}

func findNextAvailable(s *StringSet, candidate string) string {
	i := 1
	nextCandidate := candidate+strconv.Itoa(i)
	for s.Has(nextCandidate) {
		i += 1
		nextCandidate = candidate+strconv.Itoa(i)
	}
	return nextCandidate
}

type StringSet struct {
	items map[string]bool
}

func (s *StringSet) Add(t string) *StringSet {
	if s.items == nil {
		s.items = make(map[string]bool)
	}
	_, ok := s.items[t]
	if !ok {
		s.items[t] = true
	}
	return s
}

func (s *StringSet) Has(item string) bool {
	_, ok := s.items[item]
	return ok
}

package main

import "fmt"

func main() {
	var n int
	var name string

	db := make(map[string]int, 100005)

	fmt.Scanf("%d", &n)

	for i := 0; i < n; i++ {
		// Individual name
		fmt.Scanf("%s",&name)
		// Add it to the db
		count, ok := db[name]

		if !ok {
			// It does not exists yet, so lets 'create' it
			db[name] = 0
			fmt.Println("OK")
		} else {
			//Not ok. There are one or more users with
			//The same name.
			fmt.Printf("%s%d\n", name, count)
		}

		// At this point it is guaranteed to exist
		db[name]++
	}
}

package main

import "fmt"

func main() {
	var n int
	var name string

	db := make(map[string]int, 1000005)

	fmt.Scanf("%d", &n)

	for i := 0; i < n; i++ {
		// Individual name
		fmt.Scanln(&name)
		// Add it to the db
		//fmt.Println(name)

		count, exists := db[name]

		if !exists {
			//fmt.Println("Adding new")
			//db[name] = 0
			fmt.Println("OK")
		} else {
			//fmt.Println(name, "Found. Occurences: ", count)
			fmt.Printf("%s%d\n", name, count)
		}

		db[name]++
	}

	//fmt.Println(db)
}

package main

import "fmt"

func main() {
	var n int
	var name string

	db := make(map[string]int, 100005)

	fmt.Scanf("%d", &n)

	for i := 0; i < n; i++ {
		// Individual name
		fmt.Scanln(&name)
		// Add it to the db
		count, ok := db[name]

		if !ok {
			// It does not exists yet, so lets 'create' it
			db[name] = 0
			fmt.Println("Ok")
		} else {
			//Not ok. There are one or more users with
			//The same name.
			fmt.Printf("%s%d\n", name, count)
		}

		// At this point it is guaranteed to exist
		db[name]++
	}
}

package main

import (
	"fmt"
	"regexp"
)

var reg = regexp.MustCompile(`([1-9])`)

func main() {
	var count int
	fmt.Scanf("%d\n", &count)
	var strs []string
	for i := 0; i < count; i++ {
		var str string
		fmt.Scanf("%s\n", &str)
		strs = append(strs, str)
	}
	//dic := make(map[string]int)

	for _, str := range strs {
		if reg.FindStringSubmatch(str) != nil {
			fmt.Println("has number:", str)
		}
		// if count, has := dic[str]; !has {
		// 	dic[str] = 1
		// 	fmt.Println("OK")
		// } else {
		// 	fmt.Println(str + strconv.Itoa(count))
		// 	dic[str]++
		// }
	}
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var count int
	fmt.Scanf("%d\n", &count)
	var strs []string
	for i := 0; i < count; i++ {
		var str string
		fmt.Scanf("%s\n", &str)
		strs = append(strs, str)
	}
	dic := make(map[string]bool)
	var ret string
	for _, str := range strs {
		if _, has := dic[str]; !has {
			dic[str] = true
			ret = ret + "OK" + "\n"
		} else {
			for i := 1; ; i++ {
				newName := str + strconv.Itoa(i)
				if _, has := dic[newName]; !has {
					dic[newName] = true
					ret = ret + newName + "\n"
					break
				}
			}
		}
	}
	for _, str := range ret {
		fmt.Println(str)
	}
}

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
)

type login struct {
	name  []byte
	count int
}

func bytesEqual(a, b []byte) bool {
	l := len(a)
	if l != len(b) {
		return false
	}
	for i := 0; i < l; i += 1 {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func updateLogins(list []login, l []byte) ([]login, int) {
	for i := 0; i < len(list); i += 1 {
		if bytesEqual(list[i].name, l) {
			list[i].count += 1
			return list, list[i].count
		}
	}
	list = append(list, login{name: l, count: 0})
	return list, 0
}

// https://codeforces.com/problemset/problem/4/C
// комментарии к решению
// Задача хорошо ложиться на go'шный map, но при попытке использования map[string]int
// мы падаем по времени, а для []byte map не работает, поэтому реализуем на основе списков
func taskSolution(a [][]byte) string {
	seen := []login{}
	count := 0
	ans := []byte{}
	for i := 0; i < len(a); i += 1 {
		seen, count = updateLogins(seen, bytes.TrimSpace(a[i]))
		if count == 0 {
			ans = append(ans, []byte("OK\n")...)
		} else {
			strInt := []byte(fmt.Sprintln(count))
			ans = append(ans, a[i]...)
			ans = append(ans, strInt...)
		}
	}
	return string(ans[:len(ans)-1])
}

func main() {
	var n int
	if _, err := fmt.Scan(&n); err != nil {
		panic(err)
	}

	inRaw, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}
	inRawArr := bytes.Split(bytes.TrimSpace(inRaw), []byte("\n"))

	fmt.Println(taskSolution(inRawArr))
}

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
)

type login struct {
	name  []byte
	count int
}

func bytesEqual(a, b []byte) bool {
	l := len(a)
	if l != len(b) {
		return false
	}
	for i := 0; i < l; i += 1 {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func updateLogins(list []login, l []byte) ([]login, int) {
	for i := 0; i < len(list); i += 1 {
		if bytesEqual(list[i].name, l) {
			list[i].count += 1
			return list, list[i].count
		}
	}
	list = append(list, login{name: l, count: 0})
	return list, 0
}

// https://codeforces.com/problemset/problem/4/C
// комментарии к решению
// Задача хорошо ложиться на go'шный map, но при попытке использования map[string]int
// мы падаем по времени, а для []byte map не работает, поэтому реализуем на основе списков
func taskSolution(a [][]byte) string {
	seen := []login{}
	count := 0
	ans := []byte{}
	for i := 0; i < len(a); i += 1 {
		seen, count = updateLogins(seen, bytes.TrimSpace(a[i]))
		if count == 0 {
			ans = append(ans, []byte("OK\n")...)
		} else {
			strInt := []byte(fmt.Sprintln(count))
			ans = append(ans, a[i]...)
			ans = append(ans, strInt...)
		}
	}
	return string(ans)
}

func main() {
	var n int
	if _, err := fmt.Scan(&n); err != nil {
		panic(err)
	}

	inRaw, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}
	inRawArr := bytes.Split(bytes.TrimSpace(inRaw), []byte("\n"))

	fmt.Println(taskSolution(inRawArr))
}


package main

import (
	"bufio"
	. "fmt"
	"math/bits"
	"os"
)

type pstNode struct {
	l, r   int
	lo, ro *pstNode
	sum    int
}
type pst struct {
	nodes        []pstNode
	versionRoots []*pstNode
}

func (t *pst) _build(l, r int) *pstNode {
	t.nodes = append(t.nodes, pstNode{l: l, r: r})
	o := &t.nodes[len(t.nodes)-1]
	if l == r {
		return o
	}
	mid := (l + r) >> 1
	o.lo = t._build(l, mid)
	o.ro = t._build(mid+1, r)
	return o
}

func (t *pst) _update(o *pstNode, idx int, val int) *pstNode {
	t.nodes = append(t.nodes, *o)
	o = &t.nodes[len(t.nodes)-1]
	if o.l == o.r {
		o.sum += val
		return o
	}
	if mid := o.lo.r; idx <= mid {
		o.lo = t._update(o.lo, idx, val)
	} else {
		o.ro = t._update(o.ro, idx, val)
	}
	o.sum = o.lo.sum + o.ro.sum
	return o
}

func (t *pst) _query(o *pstNode, l, r int) (res int) {
	if l <= o.l && o.r <= r {
		return o.sum
	}
	mid := o.lo.r
	if l <= mid {
		res += t._query(o.lo, l, r)
	}
	if mid < r {
		res += t._query(o.ro, l, r)
	}
	return
}

func (t *pst) init(n int) {
	t.versionRoots[0] = t._build(1, n)
}

func (t *pst) update(dstVersion, srcVersion int, idx int, val int) {
	t.versionRoots[dstVersion] = t._update(t.versionRoots[srcVersion], idx, val)
}

func (t *pst) query(version int, l, r int) (sum int) {
	return t._query(t.versionRoots[version], l, r)
}

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var n, k, v, q, l, r int
	Fscan(in, &n, &k)
	t := &pst{
		make([]pstNode, 0, (bits.Len(uint(n))+2)*2*n),
		make([]*pstNode, n+1),
	}
	t.init(n)
	idx := [100001][]int{}
	for i := 1; i <= n; i++ {
		Fscan(in, &v)
		t.update(i, i-1, i, 1)
		idx[v] = append(idx[v], i)
		if sz := len(idx[v]); sz > k {
			t.update(i, i, idx[v][sz-k-1], -1)
		}
	}

	last := 0
	for Fscan(in, &q); q > 0; q-- {
		Fscan(in, &l, &r)
		l = (l+last)%n + 1
		r = (r+last)%n + 1
		if l > r {
			l, r = r, l
		}
		last = t.query(r, l, r)
		Fprintln(out, last)
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"math/bits"
	"os"
)

type pstNode struct {
	l, r   int
	lo, ro *pstNode
	sum    int
}
type pst struct {
	nodes        []pstNode
	versionRoots []*pstNode
}

func (t *pst) _build(l, r int) *pstNode {
	t.nodes = append(t.nodes, pstNode{l: l, r: r})
	o := &t.nodes[len(t.nodes)-1]
	if l == r {
		return o
	}
	mid := (l + r) >> 1
	o.lo = t._build(l, mid)
	o.ro = t._build(mid+1, r)
	return o
}

func (t *pst) _update(o *pstNode, idx int, val int) *pstNode {
	t.nodes = append(t.nodes, *o)
	o = &t.nodes[len(t.nodes)-1]
	if o.l == o.r {
		o.sum += val
		return o
	}
	if mid := o.lo.r; idx <= mid {
		o.lo = t._update(o.lo, idx, val)
	} else {
		o.ro = t._update(o.ro, idx, val)
	}
	o.sum = o.lo.sum + o.ro.sum
	return o
}

func (t *pst) _query(o *pstNode, l, r int) (res int) {
	if l <= o.l && o.r <= r {
		return o.sum
	}
	mid := o.lo.r
	if l <= mid {
		res += t._query(o.lo, l, r)
	}
	if mid < r {
		res += t._query(o.ro, l, r)
	}
	return
}

func (t *pst) init(n int) {
	t.versionRoots[0] = t._build(1, n)
}

func (t *pst) update(dstVersion, srcVersion int, idx int, val int) {
	t.versionRoots[dstVersion] = t._update(t.versionRoots[srcVersion], idx, val)
}

func (t *pst) query(version int, l, r int) (sum int) {
	return t._query(t.versionRoots[version], l, r)
}

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

	var n, k, v, q, l, r int
	Fscan(in, &n, &k)
	t := &pst{
		make([]pstNode, 0, (bits.Len(uint(n))+2)*2*n),
		make([]*pstNode, n+1),
	}
	t.init(n)
	idx := [100001][]int{}
	for i := 1; i <= n; i++ {
		Fscan(in, &v)
		t.update(i, i-1, i, 1)
		idx[v] = append(idx[v], i)
		if sz := len(idx[v]); sz > k {
			t.update(i, i, idx[v][sz-k-1], -1)
		}
	}

	last := 0
	for Fscan(in, &q); q > 0; q-- {
		Fscan(in, &l, &r)
		l = (l+last)%n + 1
		r = (r+last)%n + 1
		if l > r {
			l, r = r, l
		}
		last = t.query(r, l, r)
		Fprintln(out, last)
	}
}

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


package main

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

type pair struct {
	first  int
	second int
}
type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Less(i, j int) bool {
	if p[i].first == p[j].first {
		return p[i].second < p[j].second
	}
	return p[i].first < p[j].first
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

var n int
var d pairs
var ans pairs

func main() {
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0; i < n; i++ {
		var p pair
		fmt.Fscanf(reader, "%d", &p.first)
		p.second = i*2 + 1
		d = append(d, p)
	}
	sort.Sort(sort.Reverse(d))
	for i := 1; i < n; i++ {
		ans = append(ans, pair{d[i-1].second, d[i].second})
	}

	for i := 0; i < n; i++ {
		ans = append(ans, pair{d[i+d[i].first-1].second, d[i].second + 1})
		if d[i].first == len(d)-i {
			d = append(d, pair{0, d[i].second + 1})
		}
	}
	// fmt.Println(d)

	for i := 0; i < len(ans); i++ {
		fmt.Println(ans[i].first, ans[i].second)
	}
}

package main

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

type pair struct {
	first  int
	second int
}
type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Less(i, j int) bool {
	if p[i].first == p[j].first {
		return p[i].second < p[j].second
	}
	return p[i].first < p[j].first
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

var n int
var d pairs
var ans pairs

func main() {
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0; i < n; i++ {
		var p pair
		fmt.Fscanf(reader, "%d", &p.first)
		p.second = i*2 + 1
		d = append(d, p)
	}
	sort.Sort(sort.Reverse(d))
	for i := 1; i < n; i++ {
		ans = append(ans, pair{d[i-1].second, d[i].second})
	}
	// fmt.Println(d)

	for i := 0; i < n; i++ {
		ans = append(ans, pair{d[i+d[i].first].second, d[i].second + 1})
		if d[i].first == len(d)-1-i {
			d = append(d, pair{0, d[i].second + 1})
		}
	}

	for i := 0; i < len(ans); i++ {
		fmt.Println(ans[i].first, ans[i].second)
	}
}

package main

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

type pair struct {
	first  int
	second int
}
type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Less(i, j int) bool {
	if p[i].first == p[j].first {
		return p[i].second < p[j].second
	}
	return p[i].first < p[j].first
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

var n int
var d pairs
var ans pairs

func main() {
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0; i < n; i++ {
		var p pair
		fmt.Fscanf(reader, "%d", &p.first)
		p.second = i*2 + 1
		d = append(d, p)
	}
	sort.Sort(sort.Reverse(d))
	for i := 1; i < n; i++ {
		ans = append(ans, pair{d[i-1].second, d[i].second})
	}
	// fmt.Println(d)

	for i := 0; i < n; i++ {
		ans = append(ans, pair{d[i+d[i].first-1].second, d[i].second + 1})
		if d[i].first == len(d)-1-i {
			d = append(d, pair{0, d[i].second + 1})
		}
	}

	for i := 0; i < len(ans); i++ {
		fmt.Println(ans[i].first, ans[i].second)
	}
}


//http://codeforces.com/problemset/problem/315/A
//A. Sereja and Bottles
// van befoka masfelebol legalabb ket
// 1 1
// 2 1
// a hurokeleket is nezni kell

package main

import (
	"fmt"
)

func main() {
	var (
		n, i, a, b, max, min int32
		self, aux, frek      [1008]int32
	)

	fmt.Scan(&n)
	min = 1008
	for i = 0; i < n; i++ {
		fmt.Scan(&a)
		if a > max {
			max = a
		}
		if a < min {
			min = a
		}
		frek[a]++
		fmt.Scan(&b)
		if a != b {
			aux[b]++
		} else {
			self[a]++
		}
	}

	n = 0
	for i = min; i <= max; i++ {
		if frek[i] > 0 {
			if aux[i] > 0 || self[i] > 1 {
				continue
			}
			if 0 == self[i] {
				n += frek[i]
				continue
			}
			// self[i] itt 1, csak onmagat nem tudja kinyitni
			// az osszes tobbi azonos tipusut igen
			n++
		}
	}

	fmt.Println(n)
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func max(nums ...int64) int64 {
	var m int64
	for i, v := range nums{
		if i == 0 || v > m {
			m = v
		}
	}
	return m
}

func main() {
	var n, res int;
	scanf("%d\n", &n)
	a := make([]int, n)
	b := make([]int, n)
	types := make(map[int]int)
	for i := range a {
		scanf("%d %d\n", &a[i], &b[i])
		types[b[i]]++
	}

	for i := range a {
		types[b[i]]--
		if types[a[i]] == 0 {
			res++
		}
		types[b[i]]++
	}

	fmt.Println(res)
}

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

func main() {
	var n,i,j,k int
	k=0
	var a,b,t [105]int
	fmt.Scan(&n)
	input:= bufio.NewScanner(os.Stdin)
	input.Split(bufio.ScanWords)
	for i=1;i<=n; i++{
		input.Scan()
		aa,_:=strconv.Atoi(input.Text())
		a[i]=aa
		input.Scan()
		bb,_:=strconv.Atoi(input.Text())
		b[i]=bb
	}
	for i=1;i<=n; i++{
		for j=1;j<=n;j++ {
			if a[i]==b[j] && i!=j && t[i]==0 {
				k++
				t[i]=1
			}
		}
	}
	fmt.Println(n-k)

}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

type Bottle struct {
  Brand, Opens int
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := getI()
  bottles := make([]*Bottle, n)
  for i := 0; i < n; i++ {
    bottles[i] = &Bottle{ getI(), getI() }
  }
  result := n
  for i := 0; i < n; i++ {
    bottle := bottles[i]
    for j := 0; j < n; j++ {
      if j == i {
        continue
      }
      other := bottles[j]
      if other.Opens == bottle.Brand {
        result--
        break
      }
    }
  }
  writer.WriteString(fmt.Sprintf("%d\n", result))
}

package main

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

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

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

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

func pri(n int)    { w.WriteString(strconv.Itoa(n)) }
func prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { w.WriteByte(' ') }
func endl()        { w.WriteByte('\n') }

func main() {
  sc.Split(bufio.ScanWords)
  n := ni()
  cnt, can := make([]int, 1000), make([]int, 1000)
  for i := 0; i < n; i++ {
    a, b := ni()-1, ni()-1
    cnt[a] += 1
    if a == b {
      can[b] += 1
    } else {
      can[b] += 2
    }
  }
  ans := 0
  for i := 0; i < 1000; i++ {
    if can[i] < 1 {
      ans += cnt[i]
    } else if can[i] < 2 {
      ans += 1
    }
  }
  pri(ans)
  w.Flush()
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func max(nums ...int64) int64 {
	var m int64
	for i, v := range nums{
		if i == 0 || v > m {
			m = v
		}
	}
	return m
}

func main() {
	var n, res int;
	scanf("%d\n", &n)
	a := make([]int, n)
	b := make([]int, n)
	for i := range a {
		scanf("%d %d\n", &a[i], &b[i])
	}
	opened := make(map[int]bool)

	for i := range a {
		if a[i] != b[i] {
			opened[b[i]] = true
		}
	}

	for i := range a {
		if !opened[a[i]] {
			res++
		}
	}

	fmt.Println(res)
}

package main

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

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

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

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

func pri(n int)    { w.WriteString(strconv.Itoa(n)) }
func prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { w.WriteByte(' ') }
func endl()        { w.WriteByte('\n') }

func main() {
  sc.Split(bufio.ScanWords)
  n := ni()
  cnt, can := make([]int, 1000), make([]int, 1000)
  for i := 0; i < n; i++ {
    a, b := ni()-1, ni()-1
    cnt[a] += 1
    if a == b {
      can[b] += 1
    } else {
      can[b] += 2
    }
  }
  ans := 0
  for i := 0; i < 1000; i++ {
    if can[i] < 2 {
      ans += cnt[i]
    }
  }
  pri(ans)
  w.Flush()
}

package main

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

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

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

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

func pri(n int)    { w.WriteString(strconv.Itoa(n)) }
func prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { w.WriteByte(' ') }
func endl()        { w.WriteByte('\n') }

func main() {
  sc.Split(bufio.ScanWords)
  n := ni()
  cnt, can := make([]int, 1000), make([]int, 1000)
  for i := 0; i < n; i++ {
    a, b := ni()-1, ni()-1
    cnt[a] += 1
    if a == b {
      can[b] += 1
    } else {
      can[b] += 2
    }
  }
  ans := 0
  for i := 0; i < 1000; i++ {
    if cnt[i] > 0 && can[i] < 2 {
      ans += 1
    }
  }
  pri(ans)
  w.Flush()
}

package main

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

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

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

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

func pri(n int)    { w.WriteString(strconv.Itoa(n)) }
func prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { w.WriteByte(' ') }
func endl()        { w.WriteByte('\n') }

func main() {
  sc.Split(bufio.ScanWords)
  n := ni()
  a, b := make([]int, n), make([]int, n)
  for i := 0; i < n; i++ {
    a[i], b[i] = ni()-1, ni()-1
  }
  cnt := make([]int, 1000)
  for i := 0; i < n; i++ {
    cnt[a[i]] += 1
  }
  state := make([]int, 1000)
  for i := 0; i < n; i++ {
    if a[i] != b[i] || cnt[a[i]] > 1 {
      state[b[i]] = 1
    }
  }
  ans := 0
  for i := 0; i < 1000; i++ {
    if cnt[i] > 0 && state[i] == 0 {
      ans += 1
    }
  }
  pri(ans)
  w.Flush()
}

//http://codeforces.com/problemset/problem/315/A
//A. Sereja and Bottles
// van befoka masfelebol legalabb ket
// 1 1
// 2 1
// a hurokeleket is nezni kell

package main

import (
	"fmt"
)

func main() {
	var (
		n, i, a, b, max int32
		self, aux, frek [1008]int32
	)

	fmt.Scan(&n)
	for i = 0; i < n; i++ {
		fmt.Scan(&a)
		if a > max {
			max = a
		}
		frek[a]++
		fmt.Scan(&b)
		if a != b {
			aux[b]++
		} else {
			self[a]++
		}
	}

	n = 0
	for i = 1; i <= max; i++ {
		if frek[i] > 0 {
			if !(aux[i] > 0 || self[i] > 1) {
				n += frek[i]
			}
		}
	}

	fmt.Println(n)
}


package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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

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

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

func getPoints(a byte) int {
	return int(a) - int('a') + 1
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)
	t := io.ReadInt()
	for ; t > 0; t-- {
		a := io.ReadString()

		ans := 0
		for i := range a {
			ans += getPoints(a[i])
		}

		if len(a)%2 == 0 {
			io.Println("Alice", ans)
		} else {
			bob := min(getPoints(a[0]), getPoints(a[len(a)-1]))
			ans -= bob

			if ans > bob {
				io.Println("Alice", ans-bob)
			} else {
				io.Println("Bob", bob)
			}
		}
	}
}

package main

import (
	"fmt"
)

func min(x, y byte) byte {
	if x < y {
		return x
	}

	return y
}

func solve() {
	var s string
	fmt.Scan(&s)

	alice := 0
	for i := range s {
		alice += int(s[i] - 'a' + 1)
	}

	n := len(s)
	bob := 0
	if n % 2 != 0 {
		x := int(min(s[0] - 'a' + 1, s[n - 1] - 'a' + 1))

		alice -= x
		bob += x
	}

	if alice > bob {
		fmt.Printf("Alice %d\n", alice - bob)
	} else {
		fmt.Printf("Bob %d\n", bob - alice)
	}
}

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

	for t > 0 {
		solve()
		t--
	}
}

package main

import (
	"fmt"
	"math"
)

func min(x, y int) int {
	if x < y {
		return x
	}

	return y
}

func solve() {
	var s string
	fmt.Scan(&s)

	n := len(s)

	alice := 0
	for i := range s {
		alice += int(s[i] - 'a' + 1)
	}

	bob := 0
	if n % 2 != 0 {
		x := min(int(s[0] - 'a' + 1), int(s[n - 1] - 'a' + 1))
		alice -= x
		bob += x
	}

	diff := int(math.Abs(float64(alice - bob)))
	if alice > bob {
		fmt.Printf("Alice %d\n", diff)
	} else {
		fmt.Printf("Bob %d\n", diff)
	}
}

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

	for t > 0 {
		solve()
		t--
	}
}

package main

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

func main() {
	var (
		t int
	)

	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d\n", &t)

	for t > 0 {
		t--

		s, _ := reader.ReadString('\n')
		if s[len(s)-1] == 10 {
			s = s[:len(s)-1]
		}
		if s[len(s)-1] == 13 {
			s = s[:len(s)-1]
		}

		n := len(s)
		ans := 0
		for i := 0; i < n; i++ {
	               	ans += (int(rune(s[i]))-96)
		}

		if n & 1 == 0 {
			fmt.Println("Alice", ans)
		} else {
		      	if n == 1 {
	                	fmt.Println("Bob", (int(rune(s[0]))-96))
			} else {
				a := ans - ( int(rune(s[0])) - 96 )
				b := ans - ( int(rune(s[(n-1)])) - 96 )
				if a < b {
					a = b
				}
				c := ans - a
				if a > c {
					fmt.Println("Alice", (a-c))
				} else {
					fmt.Println("Bob", (c-a))
				}
			}
		}
	}
}

package main

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

func min(lhs, rhs int) int {
	if lhs < rhs {
		return lhs
	}
	return rhs
}

func point(b byte) int {
	return int(b-'a') + 1
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var t int
	fmt.Scanf("%d\n", &t)
	for ; t > 0; t-- {
		total := 0
		s, _ := reader.ReadString('\n')
		s = strings.TrimSpace(s)
		for i := range s {
			total = total + point(s[i])
		}
		if len(s)%2 == 0 {
			fmt.Printf("Alice %v\n", total)
		} else {
			a := total - min(point(s[0]), point(s[len(s)-1]))
			b := total - a
			if a < b {
				fmt.Printf("Bob %v\n", b-a)
			} else {
				fmt.Printf("Alice %v\n", a-b)
			}
		}
	}
}

package main

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

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

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

	t := 0
	str := ""
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		fmt.Fscan(in, &str)
		sum := 0
		for _, ch := range str {
			sum += int(ch - 'a' + 1)
		}
		if len(str)%2 == 0 {
			fmt.Fprintln(out, "Alice ", sum)
		} else if len(str) == 1 {
			fmt.Fprintln(out, "Bob ", sum)
		} else {
			diff := max(sum-int(str[0]-'a'+1)-int(str[0]-'a'+1), sum-int(str[len(str)-1]-'a'+1)-int(str[len(str)-1]-'a'+1))
			if diff < 0 {
				fmt.Fprintln(out, "Bob ", diff)
			} else {
				fmt.Fprintln(out, "Alice", diff)
			}
		}
	}
}

func max(i, j int) int {
	if i > j {
		return i
	}
	return j
}

package main

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

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

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

func main() {
	defer out.Flush()

	var tc int
	fmt.Fscan(in, &tc)
	for ; tc > 0; tc-- {
		var a string
		fmt.Fscan(in, &a)
		var ans int = 0
		for _, c := range a {
			ans += int(c - 'a' + 1)
		}
		if len(a) == 1 {
			fmt.Fprintln(out, "Bob", ans)
		} else if len(a)%2 == 0 {
			fmt.Fprintln(out, "Alice", ans)
		} else {
			b := min(int(a[len(a)-1]-'a'+1), int(a[0]-'a'+1))
			al := ans - b
			fmt.Fprintln(out, "Alice", al-b)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var testCases int
	fmt.Scanf("%d\n", &testCases)

	for i := 0; i < int(testCases); i++ {
		var str string
		fmt.Scanf("%s\n", &str)
		total := 0
		for _, c := range str {
			total += (int(c - 'a')) + 1
		}
		if len(str)%2 == 0 {
			fmt.Println("Alice", total)
			continue
		}
		if len(str) == 1 {
			fmt.Println("Bob", total)
			continue
		}
		first := int(str[0]-'a') + 1
		last := int(str[len(str)-1]-'a') + 1
		var alice int
		var bob int
		if first > last {
			alice = (total - last)
			bob = last
		} else {
			alice = (total - first)
			bob = first
		}

		fmt.Println("Alice", alice-bob)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var T int
	var S string

	fmt.Fscan(in, &T)
	//list := make([]string,N)

	for i := 0;i < T;i++{
		fmt.Fscan(in, &S)
		val := len(S)
		if val == 1{
			fmt.Println("Bob",srtToNum(S))
		}else{
			if val%2 == 1{
				if S[0] < S[val-1]{
					fmt.Println("Alice",srtToNum(S[1:val])-int(S[0])+96)
				}else{
					fmt.Println("Alice",srtToNum(S[0:val-1])-int(S[val-1])+96)
				}
			}else{
				fmt.Println("Alice",srtToNum(S))
			}
		}
	}
}

func srtToNum(S string) int{
	var i int32
	a := rune('a')
	for _,v := range S{
		i += v-a+1
	}
	return 	int(i)
}

package main

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

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

func solve() {
	var s string
	fmt.Fscan(in, &s)
	cnt := 0
	for _, v := range s {
		cnt += int(v - 'a' + 1)
	}
	if len(s)%2 == 0 {
		fmt.Fprint(out, "Alice ")
		fmt.Fprintln(out, cnt)
		return
	}
	if s[0] > s[len(s)-1] {
		cnt = cnt - int(s[len(s)-1]-'a'+1)*2
	} else {
		cnt = cnt - int(s[0]-'a'+1)*2
	}
	if cnt >= 0 {
		fmt.Fprint(out, "Alice ")
	} else {
		fmt.Fprint(out, "Bob ")
		cnt = -cnt
	}
	fmt.Fprintln(out, cnt)
}
func main() {
	t := 0
	fmt.Fscan(in, &t)
	defer out.Flush()
	for i := 0; i < t; i++ {
		//	fmt.Printf("i: %v\n", i)
		solve()
	}
}

package main

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

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

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 s string
		fmt.Fscan(in, &s)

		var sum int64
		for _, ch := range s {
			sum += int64(ch - 'a' + 1)
		}

		if len(s) == 1 {
			fmt.Fprintln(out, "Bob", sum)
		} else if len(s)%2 == 0 {
			fmt.Fprintln(out, "Alice", sum)
		} else {
			b := min(int64(s[0]-'a'+1), int64(s[len(s)-1]-'a'+1))
			a := sum - b
			fmt.Fprintln(out, "Alice", a-b)
		}
	}
}

package main

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

func main() {
	var (
		t int
	)

	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d\n", &t)

	for t > 0 {
		t--

		s, _ := reader.ReadString('\n')
		if s[len(s)-1] == 10 {
			s = s[:len(s)-1]
		}
		if s[len(s)-1] == 13 {
			s = s[:len(s)-1]
		}

		n := len(s)
		if n & 1 == 0 {
			ans := 0
			for i := 0; i < n; i++ {
	                	ans += (int(rune(s[i]))-96)
			}
			fmt.Println("Alice", ans)
		} else {
		      	if n == 1 {
	                	fmt.Println("Bob", (int(rune(s[0]))-96))
			} else {
				index := -1
				largest := -1
				for i := 0; i < n; i++ {
					if int(rune(s[i])) > largest {
	                			largest = int(rune(s[i]))
						index = i
					}
				}
				if index != 0 {
					a := s[1:]
					b := s[0]
					ans := 0
					for i := 0; i < len(a); i++ {
	                			ans += (int(rune(a[i]))-96)
					}
					ans1 := ( int(rune(b)) - 96 )
					if ans > ans1 {
						fmt.Println("Alice", int(math.Abs(float64((ans-ans1)))))
					} else {
						fmt.Println("Bob", int(math.Abs(float64((ans-ans1)))))
					}
				} else {
					a := s[:(n-1)]
					b := s[(n-1)]
					ans := 0
					for i := 0; i < len(a); i++ {
	                			ans += (int(rune(a[i]))-96)
					}
					ans1 := ( int(rune(b)) - 96 )
					if ans > ans1 {
						fmt.Println("Alice", int(math.Abs(float64((ans-ans1)))))
					} else {
						fmt.Println("Bob", int(math.Abs(float64((ans-ans1)))))
					}
				}
			}
		}
	}
}

package main

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

func min(lhs, rhs int) int {
	if lhs < rhs {
		return lhs
	}
	return rhs
}

func point(b byte) int {
	return int(b-'a') + 1
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var t int
	fmt.Scanf("%d", &t)
	for ; t > 0; t-- {
		total := 0
		s, _ := reader.ReadString('\n')
		s = s[:len(s)-1]
		for i := range s {
			total = total + point(s[i])
		}
		if len(s)%2 == 0 {
			fmt.Printf("Alice %v\n", total)
		} else {
			a := total - min(point(s[0]), point(s[len(s)-1]))
			b := total - a
			if a < b {
				fmt.Printf("Bob %v\n", b-a)
			} else {
				fmt.Printf("Alice %v\n", a-b)
			}
		}
	}
}


package main

import(
	"fmt"
	// "sort"
	// "math"
	// "strconv"
	// "strings"
	"os"
	"bufio"
)

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 toInt(buf []byte) (o int) {
	for _, v := range buf {
		o = o*10 + int(v-'0')
	}
	return
}

type pair struct {
	first int
	second int
}

type pairs []pair

func (a pairs) Len() int {return len(a)}
func (a pairs) Swap(i,j int) {a[i], a[j] = a[j], a[i]}
func (a pairs) Less(i,j int) bool {
	return a[i].first < a[j].first
	if a[i].first > a[j].first {
		return false
	}
	return a[i].second <= a[j].second
}

var dp[5005 ][5005 ] int64
var sum[5005] int64
var MD int64 = 1000000007

func main() {
	in := bufio.NewReader(os.Stdin)
	//in, _ := os.Open("a.txt")
	var n int
	fmt.Fscanf(in, "%d\n", &n)
	var prev uint8
	fmt.Fscanf(in, "%c\n", &prev)
	dp[0][0] = 1
	for i := 1; i <n; i++ {
		var c uint8
		fmt.Fscanf(in, "%c\n", &c)
		if prev == 'f' {
			for j := 0; j <=n; j++ {
				dp[i][j + 1] = dp[i - 1][j]
			}
		} else {
			for j :=n; j >= 0; j-- {
				sum[j] = (sum[j + 1] + dp[i - 1][j]) % MD
			}
			for j:=0; j <=n; j++ {
				dp[i][j] = sum[j]
			}
		}
		prev = c
	}
	var ans int64
	for j := 0; j <=n; j++ {
		ans += dp[n - 1][j]
		ans %= MD
	}
	fmt.Println(ans)
}