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

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

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

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

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

g = A("g")
l = B("l")
k = C("k")
e = D("e")
d = E("d")
m = A("m")

g.p = k
g.y = k
g.u = l
l.o = k
l.r = k
l.s = e
k.q = d
k.w = g
k.p = l
k.z = l
e.s = g
e.x = g
e.o = d
e.q = d
d.v = k
d.q = e
d.t = l
m.p = k
m.y = k
m.u = l
assert l.s.s.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: B = None
        self.y: C = None
        self.txt = txt

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

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

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

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

g = A("g")
l = B("l")
k = C("k")
e = D("e")
d = E("d")
m = A("m")

g.p = k
g.y = k
g.u = l
l.o = k
l.r = k
l.s = e
k.q = d
k.w = g
k.p = l
k.z = l
e.s = g
e.x = g
e.o = d
e.q = d
d.v = k
d.q = e
d.t = l
m.p = k
m.y = k
m.u = l
assert l.s.s.p.w.txt == "g"