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

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

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

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

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

h.x = k
h.q = j
j.o = e
j.z = f
f.r = g
f.v = m
f.w = m
f.q = c
g.p = d
m.r = k
m.v = f
m.w = i
m.q = c
k.p = c
i.r = k
i.v = d
i.w = f
i.q = f
c.r = k
c.v = m
c.w = f
c.q = i
e.o = j
e.z = c
d.r = g
d.v = i
d.w = m
d.q = m
assert m.q.q.w.w.v.r.p.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: B = None
        self.txt = txt

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

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

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

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

h.x = k
h.q = j
j.o = e
j.z = f
f.r = g
f.v = m
f.w = m
f.q = c
g.p = d
m.r = k
m.v = f
m.w = i
m.q = c
k.p = c
i.r = k
i.v = d
i.w = f
i.q = f
c.r = k
c.v = m
c.w = f
c.q = i
e.o = j
e.z = c
d.r = g
d.v = i
d.w = m
d.q = m
assert m.q.q.w.w.v.r.p.r.p.txt == "d"