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

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.x: A = None
        self.z: C = None
        self.txt = txt

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

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

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.x: A = None
        self.z: C = None
        self.txt = txt

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

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