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

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

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

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

d = A("d")
e = B("e")
a = C("a")
m = D("m")
c = D("c")
g = B("g")
i = B("i")

d.p = e
d.o = c
d.y = i
e.y = a
a.x = d
a.t = e
m.p = d
m.r = d
m.u = d
m.z = a
c.p = d
c.r = d
c.u = d
c.z = a
g.y = a
i.y = a
assert d.p.y.t.y.x.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: D = None
        self.y: B = None
        self.txt = txt

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

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

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

d = A("d")
e = B("e")
a = C("a")
m = D("m")
c = D("c")
g = B("g")
i = B("i")

d.p = e
d.o = c
d.y = i
e.y = a
a.x = d
a.t = e
m.p = d
m.r = d
m.u = d
m.z = a
c.p = d
c.r = d
c.u = d
c.z = a
g.y = a
i.y = a
assert d.p.y.t.y.x.o.z.txt == "a"