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

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

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

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

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

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

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

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

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