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

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

c = A("c")
l = B("l")
j = B("j")
n = B("n")
g = A("g")
e = A("e")
b = B("b")
a = A("a")
d = A("d")

c.x = l
l.z = j
j.z = b
n.z = l
g.x = j
e.x = j
b.z = n
a.x = l
d.x = j
assert g.x.z.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

c = A("c")
l = B("l")
j = B("j")
n = B("n")
g = A("g")
e = A("e")
b = B("b")
a = A("a")
d = A("d")

c.x = l
l.z = j
j.z = b
n.z = l
g.x = j
e.x = j
b.z = n
a.x = l
d.x = j
assert g.x.z.z.z.z.z.z.z.txt == "l"