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

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

e = A("e")
j = B("j")
a = A("a")
n = A("n")
i = B("i")
f = B("f")
k = B("k")

e.u = a
j.q = a
j.u = a
a.u = n
n.u = a
i.q = n
i.u = a
f.q = a
f.u = e
k.q = a
k.u = n
assert a.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

e = A("e")
j = B("j")
a = A("a")
n = A("n")
i = B("i")
f = B("f")
k = B("k")

e.u = a
j.q = a
j.u = a
a.u = n
n.u = a
i.q = n
i.u = a
f.q = a
f.u = e
k.q = a
k.u = n
assert a.u.u.u.u.txt == "a"