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

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

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

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

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

a = A("a")
f = B("f")
e = C("e")
j = D("j")
l = E("l")
k = A("k")
m = E("m")
h = C("h")
g = D("g")

a.s = h
f.o = h
f.p = h
e.o = g
e.y = a
j.q = m
j.z = g
j.t = h
l.p = f
k.s = e
m.p = f
h.o = j
h.y = k
g.q = m
g.z = j
g.t = e
assert h.y.s.y.s.y.s.o.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

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

a = A("a")
f = B("f")
e = C("e")
j = D("j")
l = E("l")
k = A("k")
m = E("m")
h = C("h")
g = D("g")

a.s = h
f.o = h
f.p = h
e.o = g
e.y = a
j.q = m
j.z = g
j.t = h
l.p = f
k.s = e
m.p = f
h.o = j
h.y = k
g.q = m
g.z = j
g.t = e
assert h.y.s.y.s.y.s.o.q.p.txt == "f"