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

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

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

a = A("a")
h = B("h")
n = C("n")
m = B("m")

a.q = m
a.y = n
h.t = m
h.o = n
n.y = m
n.q = h
m.t = h
m.o = n
assert m.t.o.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.y: C = None
        self.txt = txt

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

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

a = A("a")
h = B("h")
n = C("n")
m = B("m")

a.q = m
a.y = n
h.t = m
h.o = n
n.y = m
n.q = h
m.t = h
m.o = n
assert m.t.o.q.o.txt == "n"