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

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

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

b = A("b")
f = B("f")
c = C("c")
d = C("d")
a = B("a")
e = A("e")

b.q = d
b.u = a
b.t = e
f.s = c
f.q = a
f.p = a
c.q = f
c.y = f
d.q = f
d.y = a
a.s = d
a.q = f
a.p = f
e.q = c
e.u = f
e.t = b
assert c.q.q.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.u: B = None
        self.t: A = None
        self.txt = txt

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

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

b = A("b")
f = B("f")
c = C("c")
d = C("d")
a = B("a")
e = A("e")

b.q = d
b.u = a
b.t = e
f.s = c
f.q = a
f.p = a
c.q = f
c.y = f
d.q = f
d.y = a
a.s = d
a.q = f
a.p = f
e.q = c
e.u = f
e.t = b
assert c.q.q.s.q.txt == "f"