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

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

class C:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: B = None
        self.t: A = None
        self.txt = txt

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

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

g.z = d
g.s = n
i.p = g
j.r = a
j.o = d
j.t = g
k.z = a
k.s = j
k.t = j
d.p = g
n.z = a
n.t = a
n.s = j
a.r = j
a.o = d
a.t = g
assert d.p.s.s.t.z.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: B = None
        self.t: A = None
        self.txt = txt

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

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

g.z = d
g.s = n
i.p = g
j.r = a
j.o = d
j.t = g
k.z = a
k.s = j
k.t = j
d.p = g
n.z = a
n.t = a
n.s = j
a.r = j
a.o = d
a.t = g
assert d.p.s.s.t.z.p.s.txt == "n"