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

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

c = A("c")
f = B("f")
d = A("d")
b = B("b")
e = A("e")

c.v = b
f.y = e
d.v = f
b.y = d
e.v = f
assert d.v.y.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

c = A("c")
f = B("f")
d = A("d")
b = B("b")
e = A("e")

c.v = b
f.y = e
d.v = f
b.y = d
e.v = f
assert d.v.y.v.y.v.txt == "f"