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

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

c = A("c")
n = B("n")
l = A("l")
m = A("m")
k = A("k")
i = A("i")

c.w = k
n.o = k
n.v = c
l.w = c
m.w = i
k.w = m
i.w = m
assert m.w.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.o: A = None
        self.v: A = None
        self.txt = txt

c = A("c")
n = B("n")
l = A("l")
m = A("m")
k = A("k")
i = A("i")

c.w = k
n.o = k
n.v = c
l.w = c
m.w = i
k.w = m
i.w = m
assert m.w.w.w.txt == "i"