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

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

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

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

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

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

a.y = b
i.v = a
h.v = n
c.y = k
b.v = c
j.y = h
k.v = a
n.y = i
assert c.y.v.y.v.y.v.txt == "a"