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

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

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

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

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

g = A("g")
f = B("f")
h = C("h")
l = D("l")
b = E("b")
a = C("a")
c = E("c")
n = B("n")
m = D("m")
d = C("d")

g.w = h
f.u = n
f.r = c
h.x = g
l.y = b
l.t = c
l.q = n
l.o = a
b.y = g
b.o = g
b.x = c
a.x = g
c.y = g
c.o = g
c.x = b
n.u = f
n.r = b
m.y = c
m.t = b
m.q = f
m.o = a
d.x = g
assert n.r.x.x.x.y.w.x.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

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

g = A("g")
f = B("f")
h = C("h")
l = D("l")
b = E("b")
a = C("a")
c = E("c")
n = B("n")
m = D("m")
d = C("d")

g.w = h
f.u = n
f.r = c
h.x = g
l.y = b
l.t = c
l.q = n
l.o = a
b.y = g
b.o = g
b.x = c
a.x = g
c.y = g
c.o = g
c.x = b
n.u = f
n.r = b
m.y = c
m.t = b
m.q = f
m.o = a
d.x = g
assert n.r.x.x.x.y.w.x.w.x.txt == "g"