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

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: B = None
        self.w: C = None
        self.txt = txt

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

m = A("m")
h = B("h")
f = C("f")
b = B("b")
k = A("k")
j = B("j")

m.x = j
m.o = f
h.p = m
h.q = j
h.w = f
f.z = m
b.p = k
b.q = j
b.w = f
k.x = j
k.o = f
j.p = m
j.q = b
j.w = f
assert f.z.o.z.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.o: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: B = None
        self.w: C = None
        self.txt = txt

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

m = A("m")
h = B("h")
f = C("f")
b = B("b")
k = A("k")
j = B("j")

m.x = j
m.o = f
h.p = m
h.q = j
h.w = f
f.z = m
b.p = k
b.q = j
b.w = f
k.x = j
k.o = f
j.p = m
j.q = b
j.w = f
assert f.z.o.z.o.z.txt == "m"