class A:
    def __init__(self, txt: str):
        self.t: E = None
        self.p: B = None
        self.q: B = None
        self.w: B = None
        self.txt = txt

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

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

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

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

n = A("n")
h = B("h")
m = C("m")
l = D("l")
e = E("e")
g = B("g")

n.t = e
n.p = h
n.q = h
n.w = g
h.p = g
h.o = e
m.z = e
l.y = g
e.z = l
e.p = l
e.y = h
g.p = h
g.o = e
assert l.y.p.o.y.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: E = None
        self.p: B = None
        self.q: B = None
        self.w: B = None
        self.txt = txt

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

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

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

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

n = A("n")
h = B("h")
m = C("m")
l = D("l")
e = E("e")
g = B("g")

n.t = e
n.p = h
n.q = h
n.w = g
h.p = g
h.o = e
m.z = e
l.y = g
e.z = l
e.p = l
e.y = h
g.p = h
g.o = e
assert l.y.p.o.y.o.p.txt == "l"