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

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

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

f.s = d
j.u = m
j.q = b
l.u = b
l.q = e
e.u = m
e.q = j
n.s = a
m.u = j
m.q = l
a.s = d
d.s = n
b.u = m
b.q = c
c.u = j
c.q = m
assert j.u.q.u.u.q.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

f.s = d
j.u = m
j.q = b
l.u = b
l.q = e
e.u = m
e.q = j
n.s = a
m.u = j
m.q = l
a.s = d
d.s = n
b.u = m
b.q = c
c.u = j
c.q = m
assert j.u.q.u.u.q.u.u.txt == "m"