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

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

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

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

c = A("c")
a = B("a")
g = C("g")
j = D("j")
l = D("l")
k = D("k")
i = B("i")
d = A("d")
m = A("m")

c.p = l
a.r = g
a.t = g
a.v = j
g.w = c
g.t = d
g.o = m
j.s = d
j.v = a
j.q = l
l.s = m
l.v = i
l.q = k
k.s = c
k.v = a
k.q = j
i.r = g
i.t = g
i.v = l
d.p = j
m.p = k
assert m.p.v.r.w.p.s.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

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

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

c = A("c")
a = B("a")
g = C("g")
j = D("j")
l = D("l")
k = D("k")
i = B("i")
d = A("d")
m = A("m")

c.p = l
a.r = g
a.t = g
a.v = j
g.w = c
g.t = d
g.o = m
j.s = d
j.v = a
j.q = l
l.s = m
l.v = i
l.q = k
k.s = c
k.v = a
k.q = j
i.r = g
i.t = g
i.v = l
d.p = j
m.p = k
assert m.p.v.r.w.p.s.p.s.txt == "c"