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

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

m = A("m")
k = B("k")
i = B("i")
f = B("f")
c = B("c")

m.v = f
k.q = c
i.q = f
f.q = i
c.q = f
assert m.v.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

m = A("m")
k = B("k")
i = B("i")
f = B("f")
c = B("c")

m.v = f
k.q = c
i.q = f
f.q = i
c.q = f
assert m.v.q.q.q.txt == "i"