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

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

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

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

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

h = A("h")
e = B("e")
g = C("g")
a = D("a")
n = E("n")
j = D("j")
d = D("d")

h.u = g
h.p = g
h.t = e
e.p = g
e.o = n
g.u = e
a.x = j
a.o = h
a.p = n
n.x = g
j.x = a
j.o = h
j.p = n
d.x = j
d.o = h
d.p = n
assert n.x.u.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.t: B = None
        self.p: C = None
        self.txt = txt

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

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

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

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

h = A("h")
e = B("e")
g = C("g")
a = D("a")
n = E("n")
j = D("j")
d = D("d")

h.u = g
h.p = g
h.t = e
e.p = g
e.o = n
g.u = e
a.x = j
a.o = h
a.p = n
n.x = g
j.x = a
j.o = h
j.p = n
d.x = j
d.o = h
d.p = n
assert n.x.u.p.u.txt == "e"