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

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

k = A("k")
a = B("a")
c = B("c")
b = B("b")
d = A("d")
h = A("h")
e = A("e")
j = B("j")

k.x = a
k.r = j
a.z = b
a.o = b
c.z = a
c.o = j
b.z = j
b.o = a
d.x = c
d.r = j
h.x = c
h.r = a
e.x = c
e.r = a
j.z = a
j.o = b
assert c.z.z.z.z.z.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: B = None
        self.txt = txt

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

k = A("k")
a = B("a")
c = B("c")
b = B("b")
d = A("d")
h = A("h")
e = A("e")
j = B("j")

k.x = a
k.r = j
a.z = b
a.o = b
c.z = a
c.o = j
b.z = j
b.o = a
d.x = c
d.r = j
h.x = c
h.r = a
e.x = c
e.r = a
j.z = a
j.o = b
assert c.z.z.z.z.z.o.z.txt == "b"