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

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

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

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

k = A("k")
n = B("n")
h = C("h")
i = D("i")
j = A("j")
c = D("c")
a = C("a")
d = C("d")
g = B("g")
l = C("l")

k.u = a
n.u = k
h.p = c
h.t = c
h.z = n
i.s = n
i.w = j
j.u = a
c.s = g
c.w = j
a.p = c
a.t = i
a.z = n
d.p = i
d.t = i
d.z = g
g.u = k
l.p = i
l.t = c
l.z = g
assert g.u.u.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

k = A("k")
n = B("n")
h = C("h")
i = D("i")
j = A("j")
c = D("c")
a = C("a")
d = C("d")
g = B("g")
l = C("l")

k.u = a
n.u = k
h.p = c
h.t = c
h.z = n
i.s = n
i.w = j
j.u = a
c.s = g
c.w = j
a.p = c
a.t = i
a.z = n
d.p = i
d.t = i
d.z = g
g.u = k
l.p = i
l.t = c
l.z = g
assert g.u.u.p.w.txt == "j"