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

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

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

i = A("i")
m = B("m")
d = C("d")
h = A("h")
a = C("a")

i.z = h
i.o = h
m.s = h
d.q = h
d.t = h
h.z = i
h.o = i
a.q = i
a.t = h
assert i.o.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.o: A = None
        self.txt = txt

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

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

i = A("i")
m = B("m")
d = C("d")
h = A("h")
a = C("a")

i.z = h
i.o = h
m.s = h
d.q = h
d.t = h
h.z = i
h.o = i
a.q = i
a.t = h
assert i.o.z.z.txt == "h"