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

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

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

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

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

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

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

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

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

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

m.p = a
m.r = c
m.v = c
m.w = e
j.w = m
j.t = b
n.t = b
n.r = j
n.w = j
i.s = m
i.o = j
i.t = b
i.v = a
a.p = m
a.r = c
a.w = e
a.v = n
c.t = i
c.r = j
c.w = j
e.s = a
e.v = a
e.o = j
e.t = b
b.s = a
b.v = a
b.o = j
b.t = e
assert a.v.t.s.p.r.txt == "c"