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

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

f = A("f")
j = B("j")
m = A("m")
k = B("k")
c = B("c")
h = A("h")

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

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

f = A("f")
j = B("j")
m = A("m")
k = B("k")
c = B("c")
h = A("h")

f.v = c
j.v = m
m.v = j
k.v = f
c.v = h
h.v = c
assert h.v.v.v.v.v.txt == "c"