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

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

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

g = A("g")
c = B("c")
e = C("e")
h = A("h")
k = B("k")

g.o = h
c.v = h
c.s = e
c.z = k
e.x = c
e.y = g
h.o = g
k.v = h
k.s = e
k.z = c
assert g.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

g = A("g")
c = B("c")
e = C("e")
h = A("h")
k = B("k")

g.o = h
c.v = h
c.s = e
c.z = k
e.x = c
e.y = g
h.o = g
k.v = h
k.s = e
k.z = c
assert g.o.o.o.txt == "h"