class A:
    def __init__(self, txt: str):
        self.o: C = 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.z: B = None
        self.y: D = None
        self.p: D = None
        self.txt = txt

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

d = A("d")
k = B("k")
a = C("a")
i = D("i")
g = C("g")
l = B("l")
e = D("e")
h = D("h")

d.o = g
k.t = a
a.z = k
a.y = i
a.p = e
i.p = d
g.z = l
g.y = i
g.p = h
l.t = a
e.p = d
h.p = d
assert i.p.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = 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.z: B = None
        self.y: D = None
        self.p: D = None
        self.txt = txt

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

d = A("d")
k = B("k")
a = C("a")
i = D("i")
g = C("g")
l = B("l")
e = D("e")
h = D("h")

d.o = g
k.t = a
a.z = k
a.y = i
a.p = e
i.p = d
g.z = l
g.y = i
g.p = h
l.t = a
e.p = d
h.p = d
assert i.p.o.y.txt == "i"