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

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

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

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

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

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

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

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

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

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

b.v = m
i.p = b
j.p = f
j.x = i
j.u = n
j.z = n
m.o = k
m.y = h
m.w = b
d.v = f
f.o = i
f.y = h
f.w = b
h.p = b
k.p = b
n.p = f
n.x = k
n.u = j
n.z = j
assert m.w.v.w.v.y.p.v.txt == "m"