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

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

i = A("i")
a = B("a")
h = B("h")
f = B("f")
c = B("c")
e = B("e")

i.v = c
i.x = a
a.y = i
h.y = i
f.y = i
c.y = i
e.y = i
assert e.y.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.x: B = None
        self.txt = txt

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

i = A("i")
a = B("a")
h = B("h")
f = B("f")
c = B("c")
e = B("e")

i.v = c
i.x = a
a.y = i
h.y = i
f.y = i
c.y = i
e.y = i
assert e.y.x.y.txt == "i"