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

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

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

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

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

e.p = i
c.r = g
c.y = g
c.w = n
i.q = k
n.s = k
k.s = n
g.r = c
g.y = c
g.w = n
m.q = n
assert c.w.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

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

e.p = i
c.r = g
c.y = g
c.w = n
i.q = k
n.s = k
k.s = n
g.r = c
g.y = c
g.w = n
m.q = n
assert c.w.s.s.s.s.txt == "n"