#!/usr/bin/python

import random

people = ['roberto', 'david', 'marcos', 'jorge', 'javier', 'josemanuel']
gifts = ['bolsa1', 'bolsa2', 'raton', 'taza']

pref = {}

pref['roberto'] = ['bolsa1', 'bolsa2', 'taza', 'raton']
pref['david'] = ['raton']
pref['marcos'] = ['bolsa1', 'bolsa2', 'taza']
pref['jorge'] = ['taza', 'raton']
pref['javier'] = ['taza']
pref['josemanuel'] = ['bolsa1', 'bolsa2', 'taza', 'raton']

while len(gifts) > 0:
  winner = random.sample(people, 1)[0]
  for wish in pref[winner]:
	if wish in gifts: 
		print 'And the winner of the ' + wish +  ' is ' + str(winner)
		gifts.remove(wish)
		break
  people.remove(str(winner))
  if len(people) < 1: break

if len(gifts) > 0: print 'Gifts not winned: ' + str(gifts)

