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

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.txt = txt

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

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

k = A("k")
n = B("n")
m = C("m")
g = D("g")
d = E("d")

k.q = m
k.o = d
n.p = k
m.w = d
g.w = n
g.y = n
g.o = d
g.p = m
d.s = m
assert n.p.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.o: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.txt = txt

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

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

k = A("k")
n = B("n")
m = C("m")
g = D("g")
d = E("d")

k.q = m
k.o = d
n.p = k
m.w = d
g.w = n
g.y = n
g.o = d
g.p = m
d.s = m
assert n.p.o.s.txt == "m"