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

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

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

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

c.u = g
c.s = l
d.u = k
d.s = g
g.q = d
l.u = g
l.s = c
i.u = g
i.s = m
k.q = j
b.q = j
j.u = b
j.s = b
m.u = k
m.s = i
assert k.q.s.q.u.q.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.s: A = None
        self.txt = txt

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

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

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

c.u = g
c.s = l
d.u = k
d.s = g
g.q = d
l.u = g
l.s = c
i.u = g
i.s = m
k.q = j
b.q = j
j.u = b
j.s = b
m.u = k
m.s = i
assert k.q.s.q.u.q.s.q.txt == "j"