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

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

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

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

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

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

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