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

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

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

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

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

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

c.q = n
k.w = a
k.z = m
m.q = n
n.q = c
a.w = j
a.z = n
e.w = k
e.z = n
j.w = a
j.z = m
assert e.z.q.q.q.txt == "c"