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

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

c = A("c")
n = B("n")
a = B("a")
k = A("k")
e = B("e")
g = B("g")

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

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

c = A("c")
n = B("n")
a = B("a")
k = A("k")
e = B("e")
g = B("g")

c.z = k
n.q = c
a.q = k
k.z = c
e.q = c
g.q = k
assert n.q.z.z.z.txt == "k"