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

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

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

i = A("i")
c = B("c")
h = C("h")
g = A("g")
n = B("n")

i.o = n
c.o = h
h.z = c
g.o = n
n.o = h
assert h.z.o.z.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

i = A("i")
c = B("c")
h = C("h")
g = A("g")
n = B("n")

i.o = n
c.o = h
h.z = c
g.o = n
n.o = h
assert h.z.o.z.o.z.txt == "c"