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

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

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

class D:
    def __init__(self, txt: str):
        self.s: D = None
        self.o: D = None
        self.txt = txt

f = A("f")
g = B("g")
n = C("n")
l = D("l")
e = A("e")
i = A("i")
a = B("a")
m = D("m")

f.z = i
f.y = n
g.q = m
g.z = a
n.s = l
n.u = g
n.z = i
l.s = m
l.o = m
e.z = i
e.y = n
i.z = e
i.y = n
a.q = m
a.z = g
m.s = l
m.o = l
assert g.q.o.o.o.s.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.y: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.s: D = None
        self.o: D = None
        self.txt = txt

f = A("f")
g = B("g")
n = C("n")
l = D("l")
e = A("e")
i = A("i")
a = B("a")
m = D("m")

f.z = i
f.y = n
g.q = m
g.z = a
n.s = l
n.u = g
n.z = i
l.s = m
l.o = m
e.z = i
e.y = n
i.z = e
i.y = n
a.q = m
a.z = g
m.s = l
m.o = l
assert g.q.o.o.o.s.o.o.txt == "m"