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

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

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

d = A("d")
l = B("l")
g = C("g")
c = B("c")
a = A("a")
m = B("m")

d.q = a
d.u = c
l.y = g
l.s = g
l.o = a
g.t = d
c.y = g
c.s = g
c.o = a
a.q = d
a.u = m
m.y = g
m.s = g
m.o = a
assert d.q.u.o.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.u: B = None
        self.txt = txt

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

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

d = A("d")
l = B("l")
g = C("g")
c = B("c")
a = A("a")
m = B("m")

d.q = a
d.u = c
l.y = g
l.s = g
l.o = a
g.t = d
c.y = g
c.s = g
c.o = a
a.q = d
a.u = m
m.y = g
m.s = g
m.o = a
assert d.q.u.o.q.u.txt == "c"