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

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

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

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

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

i.v = k
d.x = m
d.s = i
d.q = f
k.o = i
k.p = e
a.y = n
a.v = n
a.p = d
a.x = i
l.y = n
l.p = d
l.v = m
l.x = i
f.o = i
f.p = e
g.o = i
g.p = e
n.x = m
n.s = i
n.q = f
e.y = n
e.p = m
e.v = d
e.x = i
m.x = d
m.s = i
m.q = g
assert d.q.p.v.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

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

i.v = k
d.x = m
d.s = i
d.q = f
k.o = i
k.p = e
a.y = n
a.v = n
a.p = d
a.x = i
l.y = n
l.p = d
l.v = m
l.x = i
f.o = i
f.p = e
g.o = i
g.p = e
n.x = m
n.s = i
n.q = f
e.y = n
e.p = m
e.v = d
e.x = i
m.x = d
m.s = i
m.q = g
assert d.q.p.v.q.o.txt == "i"