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

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

h = A("h")
a = B("a")
i = B("i")
j = B("j")
l = B("l")
n = B("n")
c = A("c")

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

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

h = A("h")
a = B("a")
i = B("i")
j = B("j")
l = B("l")
n = B("n")
c = A("c")

h.s = i
h.v = a
a.x = c
i.x = c
j.x = h
l.x = c
n.x = h
c.s = n
c.v = i
assert l.x.s.x.s.txt == "i"