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

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: E = None
        self.p: A = None
        self.txt = txt

a = A("a")
b = B("b")
n = C("n")
m = D("m")
i = E("i")
h = B("h")
d = D("d")
f = E("f")
g = B("g")

a.s = f
a.o = h
b.q = i
b.r = i
b.p = f
n.o = m
n.s = m
n.q = i
m.z = a
i.r = m
i.w = f
i.p = a
h.q = f
h.r = i
h.p = i
d.z = a
f.r = m
f.w = i
f.p = a
g.q = f
g.r = f
g.p = f
assert b.r.r.z.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: E = None
        self.o: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: E = None
        self.p: A = None
        self.txt = txt

a = A("a")
b = B("b")
n = C("n")
m = D("m")
i = E("i")
h = B("h")
d = D("d")
f = E("f")
g = B("g")

a.s = f
a.o = h
b.q = i
b.r = i
b.p = f
n.o = m
n.s = m
n.q = i
m.z = a
i.r = m
i.w = f
i.p = a
h.q = f
h.r = i
h.p = i
d.z = a
f.r = m
f.w = i
f.p = a
g.q = f
g.r = f
g.p = f
assert b.r.r.z.s.r.txt == "m"