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

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

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

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

g = A("g")
i = B("i")
b = C("b")
j = D("j")
m = D("m")
a = B("a")
c = A("c")
e = D("e")
n = A("n")
d = D("d")

g.r = b
g.s = a
g.w = e
g.x = j
i.r = m
i.o = e
i.u = c
i.z = c
b.z = e
j.o = n
m.o = c
a.r = e
a.o = e
a.u = g
a.z = g
c.r = b
c.s = a
c.w = e
c.x = e
e.o = c
n.r = b
n.s = a
n.w = d
n.x = j
d.o = g
assert a.z.w.o.r.z.o.r.z.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.s: B = None
        self.w: D = None
        self.x: D = None
        self.txt = txt

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

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

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

g = A("g")
i = B("i")
b = C("b")
j = D("j")
m = D("m")
a = B("a")
c = A("c")
e = D("e")
n = A("n")
d = D("d")

g.r = b
g.s = a
g.w = e
g.x = j
i.r = m
i.o = e
i.u = c
i.z = c
b.z = e
j.o = n
m.o = c
a.r = e
a.o = e
a.u = g
a.z = g
c.r = b
c.s = a
c.w = e
c.x = e
e.o = c
n.r = b
n.s = a
n.w = d
n.x = j
d.o = g
assert a.z.w.o.r.z.o.r.z.o.x.txt == "e"