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

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

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

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

k = A("k")
e = B("e")
g = C("g")
l = D("l")
n = C("n")
h = C("h")
i = D("i")
d = A("d")

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

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

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

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

k = A("k")
e = B("e")
g = C("g")
l = D("l")
n = C("n")
h = C("h")
i = D("i")
d = A("d")

k.q = d
k.y = i
k.z = h
k.x = e
e.y = k
g.y = e
g.r = e
g.q = l
g.p = d
l.x = i
l.s = i
l.r = g
l.z = e
n.y = e
n.r = e
n.q = l
n.p = d
h.y = e
h.r = e
h.q = i
h.p = k
i.x = l
i.s = l
i.r = g
i.z = e
d.q = k
d.y = l
d.z = h
d.x = e
assert e.y.x.y.z.p.q.q.txt == "k"