class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.v: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: A = None
        self.t: B = None
        self.s: A = None
        self.q: D = None
        self.txt = txt

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: A = None
        self.t: B = None
        self.s: A = None
        self.q: D = None
        self.txt = txt

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

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

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