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

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

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.u: E = None
        self.o: A = None
        self.p: E = None
        self.r: B = None
        self.txt = txt

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

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

g = A("g")
c = B("c")
i = C("i")
h = D("h")
k = E("k")
e = C("e")
m = E("m")

g.s = c
c.p = i
i.s = g
i.o = g
i.u = m
i.p = k
i.r = c
h.u = c
k.o = h
e.s = g
e.o = g
e.u = m
e.p = m
e.r = c
m.o = h
assert g.s.p.r.p.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.u: E = None
        self.o: A = None
        self.p: E = None
        self.r: B = None
        self.txt = txt

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

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

g = A("g")
c = B("c")
i = C("i")
h = D("h")
k = E("k")
e = C("e")
m = E("m")

g.s = c
c.p = i
i.s = g
i.o = g
i.u = m
i.p = k
i.r = c
h.u = c
k.o = h
e.s = g
e.o = g
e.u = m
e.p = m
e.r = c
m.o = h
assert g.s.p.r.p.s.s.txt == "c"