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

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

k = A("k")
c = B("c")
e = A("e")
b = A("b")
l = A("l")
m = A("m")
f = A("f")

k.w = m
c.q = b
e.w = l
b.w = m
l.w = f
m.w = e
f.w = k
assert c.q.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

k = A("k")
c = B("c")
e = A("e")
b = A("b")
l = A("l")
m = A("m")
f = A("f")

k.w = m
c.q = b
e.w = l
b.w = m
l.w = f
m.w = e
f.w = k
assert c.q.w.w.txt == "e"