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

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

i = A("i")
c = B("c")
g = A("g")
k = B("k")
j = A("j")
h = A("h")

i.v = h
c.o = j
c.s = k
g.v = h
k.o = h
k.s = c
j.v = h
h.v = g
assert h.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

i = A("i")
c = B("c")
g = A("g")
k = B("k")
j = A("j")
h = A("h")

i.v = h
c.o = j
c.s = k
g.v = h
k.o = h
k.s = c
j.v = h
h.v = g
assert h.v.v.v.v.txt == "h"