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

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

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

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

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

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

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

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

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

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

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