summaryrefslogtreecommitdiff
path: root/2010/1b/a/a.py
blob: f0128676c7f795c50a573f1355dd9fb84c7e7eaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
f = open('1.in', 'r')
o = open('1.out', 'w')

T = int(f.readline().strip())

for t in xrange(T):
    (N, M) = map(int, f.readline().strip().split(' '))
    pe = [f.readline().strip() for _n in range(N)]
    pc = [f.readline().strip() for _m in range(M)]
    
    fs = {'' : {}}
    for p in pe:
        dirs = p.split('/')
        cur = fs
        for d in dirs:
            try:
                cur = cur[d]
            except KeyError:
                cur[d] = {}
                cur = cur[d]
    
    res = (pe, pc)
    s = "Case #%d: %s\n" % (t+1, res)
    print s
    #o.write(s)