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

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

i = A("i")
h = B("h")
e = B("e")
d = A("d")
f = A("f")

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

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

i = A("i")
h = B("h")
e = B("e")
d = A("d")
f = A("f")

i.s = e
h.y = d
h.v = e
e.y = f
e.v = h
d.s = e
f.s = e
assert f.s.v.v.y.s.txt == "e"