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

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

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

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

g = A("g")
b = B("b")
i = C("i")
h = D("h")
f = D("f")
d = D("d")
l = A("l")
a = B("a")
n = C("n")
j = D("j")

g.z = n
g.q = l
g.u = b
b.s = a
b.y = a
i.p = l
h.z = n
f.z = n
d.z = i
l.z = i
l.q = g
l.u = a
a.s = b
a.y = b
n.p = l
j.z = n
assert f.z.p.z.p.q.z.p.q.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.q: A = None
        self.u: B = None
        self.txt = txt

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

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

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

g = A("g")
b = B("b")
i = C("i")
h = D("h")
f = D("f")
d = D("d")
l = A("l")
a = B("a")
n = C("n")
j = D("j")

g.z = n
g.q = l
g.u = b
b.s = a
b.y = a
i.p = l
h.z = n
f.z = n
d.z = i
l.z = i
l.q = g
l.u = a
a.s = b
a.y = b
n.p = l
j.z = n
assert f.z.p.z.p.q.z.p.q.u.s.txt == "a"