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

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

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

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

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

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

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

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

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

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

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

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

e.w = h
h.r = e
j.x = e
j.s = h
l.p = h
l.t = d
l.u = d
l.q = a
g.w = e
g.o = e
g.v = n
d.p = h
d.t = l
d.u = l
d.q = k
n.w = e
n.o = e
n.v = g
k.x = e
k.s = h
a.x = e
a.s = h
assert e.w.r.w.txt == "h"