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

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

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

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

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

a.p = e
a.y = g
e.s = k
h.z = k
h.o = e
h.p = g
d.x = e
d.q = a
d.z = k
l.p = e
l.y = g
k.z = g
k.o = e
k.p = h
n.x = e
n.q = a
n.z = g
m.x = e
m.q = a
m.z = k
g.z = h
g.p = h
g.o = e
assert a.p.s.z.o.s.o.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: C = None
        self.txt = txt

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

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

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

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

a.p = e
a.y = g
e.s = k
h.z = k
h.o = e
h.p = g
d.x = e
d.q = a
d.z = k
l.p = e
l.y = g
k.z = g
k.o = e
k.p = h
n.x = e
n.q = a
n.z = g
m.x = e
m.q = a
m.z = k
g.z = h
g.p = h
g.o = e
assert a.p.s.z.o.s.o.s.o.txt == "e"