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

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

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

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

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

h.s = i
h.z = l
n.p = a
n.v = a
n.s = h
n.z = i
g.q = i
g.o = l
a.w = g
a.q = n
a.y = h
i.p = a
i.v = a
i.s = h
i.z = n
l.w = g
l.q = n
l.y = h
assert a.q.z.s.z.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.z: D = None
        self.txt = txt

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

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

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

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

h.s = i
h.z = l
n.p = a
n.v = a
n.s = h
n.z = i
g.q = i
g.o = l
a.w = g
a.q = n
a.y = h
i.p = a
i.v = a
i.s = h
i.z = n
l.w = g
l.q = n
l.y = h
assert a.q.z.s.z.y.z.txt == "l"