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

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

j = A("j")
d = B("d")
h = B("h")
m = A("m")
l = B("l")
f = B("f")

j.v = m
d.s = l
h.s = f
m.v = j
l.s = h
f.s = d
assert j.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

j = A("j")
d = B("d")
h = B("h")
m = A("m")
l = B("l")
f = B("f")

j.v = m
d.s = l
h.s = f
m.v = j
l.s = h
f.s = d
assert j.v.v.v.v.v.v.txt == "j"