from fake_collections import deque def f(x, y, z): d = deque() l = [] for i in seq: d[x] = y l[x] = z t = 1 d[0] = t l[0] = t d[i] l[i] d[x] d[0]