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

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

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

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

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

j.v = d
j.t = c
a.o = c
a.x = i
a.y = l
a.q = m
d.u = a
d.q = j
d.v = l
d.y = m
m.p = i
m.y = j
n.p = a
n.y = j
i.o = j
i.x = e
i.y = l
i.q = n
c.v = d
c.t = j
e.o = c
e.x = i
e.y = d
e.q = n
l.u = i
l.q = c
l.v = d
l.y = n
assert j.t.t.t.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.t: A = None
        self.txt = txt

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

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

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

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

j.v = d
j.t = c
a.o = c
a.x = i
a.y = l
a.q = m
d.u = a
d.q = j
d.v = l
d.y = m
m.p = i
m.y = j
n.p = a
n.y = j
i.o = j
i.x = e
i.y = l
i.q = n
c.v = d
c.t = j
e.o = c
e.x = i
e.y = d
e.q = n
l.u = i
l.q = c
l.v = d
l.y = n
assert j.t.t.t.t.v.txt == "d"