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

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

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.v: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: A = None
        self.x: C = None
        self.y: E = None
        self.txt = txt

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

l = A("l")
b = B("b")
m = C("m")
g = D("g")
a = E("a")
n = A("n")

l.p = m
l.z = b
b.t = n
b.q = n
b.p = n
b.u = g
m.q = g
m.v = g
g.w = b
g.u = l
g.x = m
g.y = a
a.x = g
a.y = g
a.p = n
a.t = m
n.p = m
n.z = b
assert b.u.w.q.p.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.v: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: A = None
        self.x: C = None
        self.y: E = None
        self.txt = txt

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

l = A("l")
b = B("b")
m = C("m")
g = D("g")
a = E("a")
n = A("n")

l.p = m
l.z = b
b.t = n
b.q = n
b.p = n
b.u = g
m.q = g
m.v = g
g.w = b
g.u = l
g.x = m
g.y = a
a.x = g
a.y = g
a.p = n
a.t = m
n.p = m
n.z = b
assert b.u.w.q.p.q.w.txt == "b"