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

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

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

c = A("c")
d = B("d")
k = C("k")
g = C("g")
i = C("i")
a = C("a")
h = A("h")

c.z = k
d.z = k
d.o = c
d.v = g
k.t = i
k.p = d
k.o = c
g.t = a
g.p = d
g.o = h
i.t = a
i.p = d
i.o = h
a.t = i
a.p = d
a.o = h
h.z = i
assert g.t.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

c = A("c")
d = B("d")
k = C("k")
g = C("g")
i = C("i")
a = C("a")
h = A("h")

c.z = k
d.z = k
d.o = c
d.v = g
k.t = i
k.p = d
k.o = c
g.t = a
g.p = d
g.o = h
i.t = a
i.p = d
i.o = h
a.t = i
a.p = d
a.o = h
h.z = i
assert g.t.t.p.txt == "d"