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

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

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

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

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

n.s = d
n.r = d
n.x = j
g.z = e
g.o = b
a.p = g
a.v = n
a.t = d
j.w = n
d.s = n
d.r = n
d.x = j
c.z = g
c.o = b
e.z = g
e.o = b
b.p = e
b.v = n
b.t = n
assert a.v.x.w.x.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.r: A = None
        self.x: D = None
        self.txt = txt

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

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

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

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

n.s = d
n.r = d
n.x = j
g.z = e
g.o = b
a.p = g
a.v = n
a.t = d
j.w = n
d.s = n
d.r = n
d.x = j
c.z = g
c.o = b
e.z = g
e.o = b
b.p = e
b.v = n
b.t = n
assert a.v.x.w.x.w.s.txt == "d"