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

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.p: D = None
        self.s: D = None
        self.txt = txt

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

n = A("n")
m = B("m")
g = C("g")
h = D("h")

n.p = m
n.r = m
n.w = m
n.u = g
m.w = n
m.t = n
m.r = n
g.y = n
g.p = h
g.s = h
h.o = m
h.r = m
h.v = g
h.s = n
assert g.s.v.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: C = None
        self.r: B = None
        self.w: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.p: D = None
        self.s: D = None
        self.txt = txt

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

n = A("n")
m = B("m")
g = C("g")
h = D("h")

n.p = m
n.r = m
n.w = m
n.u = g
m.w = n
m.t = n
m.r = n
g.y = n
g.p = h
g.s = h
h.o = m
h.r = m
h.v = g
h.s = n
assert g.s.v.p.s.txt == "n"