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

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

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

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

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

a.x = e
a.q = i
a.y = m
a.w = l
i.r = c
i.z = n
m.s = k
c.z = a
c.p = i
c.r = g
c.x = m
l.x = g
l.q = i
l.y = m
l.w = a
f.r = n
f.z = e
n.z = l
n.p = f
n.r = g
n.x = k
k.s = m
e.z = a
e.p = f
e.r = c
e.x = k
g.z = a
g.p = f
g.r = n
g.x = k
assert k.s.s.s.s.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: B = None
        self.y: C = None
        self.w: A = None
        self.txt = txt

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

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

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

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

a.x = e
a.q = i
a.y = m
a.w = l
i.r = c
i.z = n
m.s = k
c.z = a
c.p = i
c.r = g
c.x = m
l.x = g
l.q = i
l.y = m
l.w = a
f.r = n
f.z = e
n.z = l
n.p = f
n.r = g
n.x = k
k.s = m
e.z = a
e.p = f
e.r = c
e.x = k
g.z = a
g.p = f
g.r = n
g.x = k
assert k.s.s.s.s.s.s.s.s.s.s.txt == "k"