def ccnt(m, i): c = 0 for d in range(10, i + 1): a, b = map(int, str(d)) if a + b == m: c += 1 #print m,a,b return c cnt = 0 for m in range(1, 13): if m < 10: print m, 0, m cnt += 1 if m == 2: cnt += ccnt(2, 28) elif m in (4, 6, 9, 11): cnt += ccnt(m, 30) else: cnt += ccnt(m, 31) print cnt