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

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

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

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

n = A("n")
f = B("f")
b = C("b")
d = D("d")
m = A("m")
g = A("g")

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

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

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

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

n = A("n")
f = B("f")
b = C("b")
d = D("d")
m = A("m")
g = A("g")

n.w = f
n.y = f
n.v = b
n.r = g
f.t = m
f.p = m
f.v = d
b.t = m
d.u = f
d.v = b
d.s = n
m.w = f
m.y = f
m.v = b
m.r = n
g.w = f
g.y = f
g.v = b
g.r = n
assert m.r.y.v.v.t.r.txt == "n"