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

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

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

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

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

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

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

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

j.v = m
j.o = i
k.y = g
k.o = j
k.z = i
c.s = j
c.r = g
g.y = h
g.o = j
g.z = i
i.s = m
i.r = h
h.y = k
h.o = m
h.z = c
m.v = j
m.o = c
assert h.z.s.o.s.txt == "m"