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

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

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

a = A("a")
c = B("c")
f = C("f")
m = C("m")
j = C("j")
d = C("d")
b = A("b")
l = C("l")

a.x = b
a.q = c
c.t = l
f.p = d
f.s = a
m.p = j
m.s = a
j.p = f
j.s = b
d.p = j
d.s = a
b.x = a
b.q = c
l.p = d
l.s = a
assert m.s.x.x.q.t.s.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: B = None
        self.txt = txt

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

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

a = A("a")
c = B("c")
f = C("f")
m = C("m")
j = C("j")
d = C("d")
b = A("b")
l = C("l")

a.x = b
a.q = c
c.t = l
f.p = d
f.s = a
m.p = j
m.s = a
j.p = f
j.s = b
d.p = j
d.s = a
b.x = a
b.q = c
l.p = d
l.s = a
assert m.s.x.x.q.t.s.x.x.txt == "a"