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

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

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

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

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

n.x = b
n.r = f
i.x = f
i.p = n
i.s = c
i.w = e
m.v = i
m.o = j
m.r = n
j.v = n
j.x = i
j.y = e
j.o = b
e.x = b
e.r = f
g.x = i
g.p = n
g.w = n
g.s = c
b.v = n
b.x = g
b.y = e
b.o = j
f.x = g
f.p = e
f.s = c
f.w = n
c.v = g
c.o = j
c.r = n
assert m.v.x.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.r: B = None
        self.txt = txt

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

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

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

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

n.x = b
n.r = f
i.x = f
i.p = n
i.s = c
i.w = e
m.v = i
m.o = j
m.r = n
j.v = n
j.x = i
j.y = e
j.o = b
e.x = b
e.r = f
g.x = i
g.p = n
g.w = n
g.s = c
b.v = n
b.x = g
b.y = e
b.o = j
f.x = g
f.p = e
f.s = c
f.w = n
c.v = g
c.o = j
c.r = n
assert m.v.x.s.r.txt == "n"