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

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

c = A("c")
g = B("g")
e = B("e")
d = B("d")
f = B("f")
i = A("i")
h = A("h")
l = A("l")
n = A("n")

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

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

c = A("c")
g = B("g")
e = B("e")
d = B("d")
f = B("f")
i = A("i")
h = A("h")
l = A("l")
n = A("n")

c.t = i
c.v = e
g.z = n
e.z = h
d.z = h
f.z = l
i.t = n
i.v = g
h.t = n
h.v = d
l.t = h
l.v = e
n.t = h
n.v = g
assert e.z.v.z.v.txt == "d"