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

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

k = A("k")
g = B("g")
l = A("l")
c = B("c")

k.q = l
k.w = c
g.z = k
g.w = c
l.q = k
l.w = c
c.z = k
c.w = g
assert c.z.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.w: B = None
        self.txt = txt

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

k = A("k")
g = B("g")
l = A("l")
c = B("c")

k.q = l
k.w = c
g.z = k
g.w = c
l.q = k
l.w = c
c.z = k
c.w = g
assert c.z.w.w.w.txt == "c"