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

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

n = A("n")
c = B("c")
m = A("m")
a = A("a")
f = A("f")
i = A("i")
l = A("l")
k = A("k")
j = A("j")
b = B("b")

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

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

n = A("n")
c = B("c")
m = A("m")
a = A("a")
f = A("f")
i = A("i")
l = A("l")
k = A("k")
j = A("j")
b = B("b")

n.u = j
n.y = b
c.z = b
c.q = b
m.u = n
m.y = b
a.u = i
a.y = b
f.u = n
f.y = b
i.u = j
i.y = c
l.u = n
l.y = b
k.u = n
k.y = c
j.u = l
j.y = b
b.z = c
b.q = c
assert m.u.y.z.q.q.txt == "c"