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

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

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

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

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

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

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

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

j.o = c
c.u = m
c.y = h
m.q = c
m.t = c
m.w = a
h.o = c
a.q = c
a.t = c
a.w = m
n.o = c
assert m.t.u.q.u.w.w.txt == "m"