class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.v: A = None
        self.txt = txt

b = A("b")
n = B("n")
e = B("e")
l = B("l")
f = B("f")
d = A("d")
i = A("i")
g = A("g")
a = B("a")
m = B("m")

b.t = i
n.z = b
n.v = i
e.z = g
e.v = g
l.z = d
l.v = i
f.z = d
f.v = b
d.t = i
i.t = d
g.t = b
a.z = d
a.v = b
m.z = i
m.v = d
assert l.z.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.v: A = None
        self.txt = txt

b = A("b")
n = B("n")
e = B("e")
l = B("l")
f = B("f")
d = A("d")
i = A("i")
g = A("g")
a = B("a")
m = B("m")

b.t = i
n.z = b
n.v = i
e.z = g
e.v = g
l.z = d
l.v = i
f.z = d
f.v = b
d.t = i
i.t = d
g.t = b
a.z = d
a.v = b
m.z = i
m.v = d
assert l.z.t.t.t.t.t.t.txt == "d"