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

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

k = A("k")
m = B("m")
f = A("f")
a = A("a")
l = B("l")
h = A("h")
j = B("j")
c = B("c")
e = A("e")

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

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

k = A("k")
m = B("m")
f = A("f")
a = A("a")
l = B("l")
h = A("h")
j = B("j")
c = B("c")
e = A("e")

k.u = a
k.q = l
m.s = j
f.u = e
f.q = j
a.u = h
a.q = j
l.s = j
h.u = k
h.q = c
j.s = m
c.s = m
e.u = a
e.q = j
assert k.u.q.s.txt == "m"