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

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

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

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

a = A("a")
b = B("b")
g = C("g")
e = D("e")
d = C("d")
m = A("m")
f = B("f")
k = A("k")
h = C("h")
c = D("c")

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

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

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

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

a = A("a")
b = B("b")
g = C("g")
e = D("e")
d = C("d")
m = A("m")
f = B("f")
k = A("k")
h = C("h")
c = D("c")

a.z = e
a.u = g
a.o = c
a.s = f
b.w = c
b.v = e
g.r = b
g.v = b
g.x = m
e.u = a
e.z = f
e.x = k
e.r = g
d.r = b
d.x = m
d.v = f
m.z = e
m.o = e
m.u = h
m.s = f
f.w = c
f.v = c
k.z = c
k.o = c
k.u = d
k.s = b
h.r = b
h.x = k
h.v = f
c.u = a
c.z = f
c.x = k
c.r = d
assert g.r.w.r.x.u.v.w.txt == "c"