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

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

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

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

k = A("k")
l = B("l")
n = C("n")
e = D("e")
a = B("a")
h = B("h")

k.v = l
k.q = a
l.o = n
l.v = a
l.x = k
l.u = h
n.s = e
n.x = k
e.p = k
e.s = k
e.z = k
a.o = n
a.v = h
a.x = k
a.u = l
h.o = n
h.v = a
h.x = k
h.u = l
assert n.s.p.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.q: B = None
        self.txt = txt

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

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

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

k = A("k")
l = B("l")
n = C("n")
e = D("e")
a = B("a")
h = B("h")

k.v = l
k.q = a
l.o = n
l.v = a
l.x = k
l.u = h
n.s = e
n.x = k
e.p = k
e.s = k
e.z = k
a.o = n
a.v = h
a.x = k
a.u = l
h.o = n
h.v = a
h.x = k
h.u = l
assert n.s.p.v.x.txt == "k"