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

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

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

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

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

d = A("d")
n = B("n")
b = C("b")
g = D("g")
h = E("h")
k = D("k")

d.v = n
d.s = n
d.w = k
d.p = b
n.p = h
n.r = d
b.z = n
b.y = n
b.r = k
b.x = g
g.r = h
g.v = b
g.p = b
g.u = d
h.w = g
k.r = h
k.v = b
k.p = b
k.u = d
assert b.z.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.s: B = None
        self.w: D = None
        self.p: C = None
        self.txt = txt

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

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

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

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

d = A("d")
n = B("n")
b = C("b")
g = D("g")
h = E("h")
k = D("k")

d.v = n
d.s = n
d.w = k
d.p = b
n.p = h
n.r = d
b.z = n
b.y = n
b.r = k
b.x = g
g.r = h
g.v = b
g.p = b
g.u = d
h.w = g
k.r = h
k.v = b
k.p = b
k.u = d
assert b.z.p.w.txt == "g"