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

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

c = A("c")
m = B("m")
j = A("j")
f = B("f")
k = B("k")
a = A("a")
d = B("d")

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

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

c = A("c")
m = B("m")
j = A("j")
f = B("f")
k = B("k")
a = A("a")
d = B("d")

c.q = k
m.y = j
m.u = j
j.q = k
f.y = a
f.u = c
k.y = j
k.u = j
a.q = m
d.y = a
d.u = a
assert m.u.q.y.q.u.q.u.txt == "j"