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

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

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

a.v = i
a.s = c
i.u = h
c.v = i
c.s = a
h.u = i
assert h.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.s: A = None
        self.txt = txt

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

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

a.v = i
a.s = c
i.u = h
c.v = i
c.s = a
h.u = i
assert h.u.u.u.u.txt == "h"