class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.y: D = None
        self.x: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.u: C = None
        self.txt = txt

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

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

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

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

a.u = k
a.y = k
a.x = k
h.x = b
h.u = m
m.o = n
m.w = h
m.y = h
m.z = h
k.p = h
k.v = a
k.s = m
n.w = k
b.o = n
b.w = h
b.y = h
b.z = h
assert a.u.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.y: D = None
        self.x: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.u: C = None
        self.txt = txt

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

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

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

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

a.u = k
a.y = k
a.x = k
h.x = b
h.u = m
m.o = n
m.w = h
m.y = h
m.z = h
k.p = h
k.v = a
k.s = m
n.w = k
b.o = n
b.w = h
b.y = h
b.z = h
assert a.u.v.u.txt == "k"