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

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

k = A("k")
m = B("m")
a = A("a")
f = B("f")
c = A("c")
n = A("n")
b = A("b")
g = A("g")
i = A("i")
j = B("j")

k.z = f
m.x = j
a.z = f
f.x = j
c.z = j
n.z = j
b.z = f
g.z = f
i.z = f
j.x = f
assert i.z.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

k = A("k")
m = B("m")
a = A("a")
f = B("f")
c = A("c")
n = A("n")
b = A("b")
g = A("g")
i = A("i")
j = B("j")

k.z = f
m.x = j
a.z = f
f.x = j
c.z = j
n.z = j
b.z = f
g.z = f
i.z = f
j.x = f
assert i.z.x.x.x.x.x.x.txt == "f"