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

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

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

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

k = A("k")
m = B("m")
f = C("f")
g = D("g")
b = B("b")
n = C("n")
h = A("h")
j = A("j")
c = D("c")
i = D("i")

k.w = j
k.v = f
k.r = b
m.x = f
f.w = g
f.p = g
f.u = m
f.z = h
g.z = i
g.x = m
b.x = n
n.w = i
n.p = i
n.u = m
n.z = k
h.w = j
h.v = n
h.r = m
j.w = k
j.v = f
j.r = b
c.z = g
c.x = b
i.z = c
i.x = m
assert n.u.x.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.v: C = None
        self.r: B = None
        self.txt = txt

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

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

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

k = A("k")
m = B("m")
f = C("f")
g = D("g")
b = B("b")
n = C("n")
h = A("h")
j = A("j")
c = D("c")
i = D("i")

k.w = j
k.v = f
k.r = b
m.x = f
f.w = g
f.p = g
f.u = m
f.z = h
g.z = i
g.x = m
b.x = n
n.w = i
n.p = i
n.u = m
n.z = k
h.w = j
h.v = n
h.r = m
j.w = k
j.v = f
j.r = b
c.z = g
c.x = b
i.z = c
i.x = m
assert n.u.x.z.r.txt == "m"