class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: E = None
        self.w: D = None
        self.p: D = None
        self.x: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.p: E = None
        self.o: A = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.w: B = None
        self.z: C = None
        self.txt = txt

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

h.u = n
h.x = n
h.q = b
h.w = d
h.p = d
k.s = h
n.z = b
n.p = b
n.o = h
d.p = b
d.u = b
b.w = k
b.z = n
assert n.p.w.s.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: E = None
        self.w: D = None
        self.p: D = None
        self.x: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.p: E = None
        self.o: A = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.w: B = None
        self.z: C = None
        self.txt = txt

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

h.u = n
h.x = n
h.q = b
h.w = d
h.p = d
k.s = h
n.z = b
n.p = b
n.o = h
d.p = b
d.u = b
b.w = k
b.z = n
assert n.p.w.s.w.p.txt == "b"