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

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

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

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

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

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

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

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

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