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

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: C = None
        self.r: D = None
        self.txt = txt

h = A("h")
f = B("f")
l = C("l")
g = D("g")
a = E("a")
i = C("i")

h.u = i
h.v = f
h.x = f
h.p = l
f.u = g
f.p = l
l.s = f
l.q = f
l.p = h
l.z = h
l.t = h
g.w = h
a.t = l
a.r = g
i.s = f
i.q = f
i.p = h
i.z = h
i.t = h
assert l.t.x.u.w.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.v: B = None
        self.x: B = None
        self.p: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: C = None
        self.r: D = None
        self.txt = txt

h = A("h")
f = B("f")
l = C("l")
g = D("g")
a = E("a")
i = C("i")

h.u = i
h.v = f
h.x = f
h.p = l
f.u = g
f.p = l
l.s = f
l.q = f
l.p = h
l.z = h
l.t = h
g.w = h
a.t = l
a.r = g
i.s = f
i.q = f
i.p = h
i.z = h
i.t = h
assert l.t.x.u.w.p.q.txt == "f"