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

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

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

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

l = A("l")
i = B("i")
d = C("d")
g = D("g")
c = D("c")
n = A("n")
a = C("a")
b = C("b")
j = B("j")

l.r = g
l.v = g
l.z = i
i.v = j
d.x = l
g.s = a
g.o = a
g.q = n
c.s = d
c.o = a
c.q = n
n.r = c
n.z = j
n.v = g
a.x = l
b.x = l
j.v = i
assert l.z.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.z: B = None
        self.v: D = None
        self.txt = txt

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

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

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

l = A("l")
i = B("i")
d = C("d")
g = D("g")
c = D("c")
n = A("n")
a = C("a")
b = C("b")
j = B("j")

l.r = g
l.v = g
l.z = i
i.v = j
d.x = l
g.s = a
g.o = a
g.q = n
c.s = d
c.o = a
c.q = n
n.r = c
n.z = j
n.v = g
a.x = l
b.x = l
j.v = i
assert l.z.v.v.v.v.txt == "i"