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

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

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

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

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

b.p = g
b.w = m
n.p = e
n.w = i
n.r = b
n.t = g
j.z = e
j.o = a
j.q = b
j.u = b
m.p = h
m.q = b
i.z = e
i.o = a
i.q = b
i.u = b
g.p = e
g.w = i
g.r = b
g.t = h
e.p = g
e.q = b
f.p = m
f.w = a
f.r = b
f.t = h
h.p = m
h.w = a
h.r = b
h.t = n
a.z = e
a.o = j
a.q = b
a.u = b
assert g.t.w.o.u.w.q.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.w: D = None
        self.txt = txt

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

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

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

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

b.p = g
b.w = m
n.p = e
n.w = i
n.r = b
n.t = g
j.z = e
j.o = a
j.q = b
j.u = b
m.p = h
m.q = b
i.z = e
i.o = a
i.q = b
i.u = b
g.p = e
g.w = i
g.r = b
g.t = h
e.p = g
e.q = b
f.p = m
f.w = a
f.r = b
f.t = h
h.p = m
h.w = a
h.r = b
h.t = n
a.z = e
a.o = j
a.q = b
a.u = b
assert g.t.w.o.u.w.q.p.r.txt == "b"