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

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

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

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

g = A("g")
j = B("j")
b = C("b")
m = D("m")
k = B("k")
l = C("l")
d = A("d")
h = D("h")
n = D("n")

g.z = b
g.q = m
g.v = n
g.s = d
j.q = l
j.v = d
j.x = m
j.t = k
b.x = g
b.q = d
m.z = l
m.q = g
k.q = b
k.v = d
k.x = m
k.t = j
l.x = d
l.q = d
d.z = l
d.q = m
d.v = m
d.s = g
h.z = l
h.q = g
n.z = l
n.q = g
assert n.z.x.v.q.q.z.x.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.q: D = None
        self.v: D = None
        self.s: A = None
        self.txt = txt

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

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

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

g = A("g")
j = B("j")
b = C("b")
m = D("m")
k = B("k")
l = C("l")
d = A("d")
h = D("h")
n = D("n")

g.z = b
g.q = m
g.v = n
g.s = d
j.q = l
j.v = d
j.x = m
j.t = k
b.x = g
b.q = d
m.z = l
m.q = g
k.q = b
k.v = d
k.x = m
k.t = j
l.x = d
l.q = d
d.z = l
d.q = m
d.v = m
d.s = g
h.z = l
h.q = g
n.z = l
n.q = g
assert n.z.x.v.q.q.z.x.z.x.txt == "d"