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

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: D = None
        self.txt = txt

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

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

b = A("b")
k = B("k")
e = C("e")
g = D("g")
n = C("n")
d = D("d")
a = B("a")

b.q = g
b.w = g
b.z = n
b.p = a
k.u = a
k.w = d
e.y = k
e.u = g
e.q = b
e.s = a
g.q = n
n.y = k
n.s = k
n.u = d
n.q = b
d.q = n
a.u = k
a.w = g
assert n.q.z.q.z.q.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.w: D = None
        self.z: C = None
        self.p: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: D = None
        self.txt = txt

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

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

b = A("b")
k = B("k")
e = C("e")
g = D("g")
n = C("n")
d = D("d")
a = B("a")

b.q = g
b.w = g
b.z = n
b.p = a
k.u = a
k.w = d
e.y = k
e.u = g
e.q = b
e.s = a
g.q = n
n.y = k
n.s = k
n.u = d
n.q = b
d.q = n
a.u = k
a.w = g
assert n.q.z.q.z.q.p.u.txt == "k"