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

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

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

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

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

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

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

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

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

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

n.p = i
n.r = i
n.x = a
n.w = c
d.r = l
d.w = g
d.q = a
m.p = a
c.o = a
c.p = n
c.r = k
c.v = d
a.r = n
a.w = g
a.q = d
l.p = c
l.r = c
l.x = a
l.w = i
k.o = a
k.v = a
k.p = l
k.r = i
i.o = a
i.p = l
i.r = k
i.v = d
g.p = a
assert i.v.w.p.q.r.txt == "l"