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

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

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

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

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

k.y = d
k.q = l
k.w = a
k.t = i
a.t = g
a.q = g
d.s = l
d.v = l
d.x = i
l.t = i
n.s = l
n.v = l
n.x = i
g.t = a
g.q = a
i.y = n
i.q = l
i.w = g
i.t = k
assert a.t.t.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: D = None
        self.w: B = None
        self.t: A = None
        self.txt = txt

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

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

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

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

k.y = d
k.q = l
k.w = a
k.t = i
a.t = g
a.q = g
d.s = l
d.v = l
d.x = i
l.t = i
n.s = l
n.v = l
n.x = i
g.t = a
g.q = a
i.y = n
i.q = l
i.w = g
i.t = k
assert a.t.t.q.q.q.q.txt == "a"