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

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

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

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

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

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

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

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

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

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

e.q = g
e.y = m
e.o = m
g.y = n
m.y = f
m.q = a
a.s = f
a.y = g
n.y = f
h.q = f
h.y = m
h.o = m
c.q = g
c.y = m
c.o = m
i.y = n
f.y = i
assert g.y.y.y.y.y.y.y.y.y.txt == "i"