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

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

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

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

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

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

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

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

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