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

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

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

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

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

j.w = c
a.r = c
a.s = m
a.p = j
a.t = k
m.o = c
m.q = i
m.r = a
i.p = n
i.u = a
i.o = k
i.q = k
h.o = c
h.q = i
h.r = a
c.o = m
c.q = i
c.r = d
k.w = m
d.r = m
d.s = m
d.p = k
d.t = j
n.p = i
n.u = a
n.o = j
n.q = j
e.r = m
e.s = c
e.p = k
e.t = j
assert a.r.o.r.p.w.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

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

j.w = c
a.r = c
a.s = m
a.p = j
a.t = k
m.o = c
m.q = i
m.r = a
i.p = n
i.u = a
i.o = k
i.q = k
h.o = c
h.q = i
h.r = a
c.o = m
c.q = i
c.r = d
k.w = m
d.r = m
d.s = m
d.p = k
d.t = j
n.p = i
n.u = a
n.o = j
n.q = j
e.r = m
e.s = c
e.p = k
e.t = j
assert a.r.o.r.p.w.q.p.txt == "n"