look into:
http://www.mathlinks.ro/viewtopic.php?p=344667#344667
In a lottery, tickets are given 9-digit nos using only the digits 1,2,3.They are also coloured red, blue or green in such a way that 2 tickets whose numbers differ in all the 9 places get different colours! Suppose the ticket bearing the nuber 122222222 is red and that bearing the number 222222222 is green. Determine the colour of the ticket 123123123.
Source :- INMO-2003