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

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

f = A("f")
i = B("i")
g = B("g")
a = B("a")
j = B("j")
e = A("e")
l = A("l")
d = A("d")

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

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

f = A("f")
i = B("i")
g = B("g")
a = B("a")
j = B("j")
e = A("e")
l = A("l")
d = A("d")

f.v = i
i.t = f
i.z = j
g.t = l
g.z = j
a.t = d
a.z = i
j.t = f
j.z = i
e.v = g
l.v = i
d.v = a
assert j.t.v.t.v.t.v.z.txt == "j"