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

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

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

class D:
    def __init__(self, txt: str):
        self.p: E = None
        self.y: B = None
        self.q: C = None
        self.s: A = None
        self.txt = txt

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

h = A("h")
i = B("i")
k = C("k")
d = D("d")
n = E("n")
c = E("c")

h.r = d
h.w = c
h.s = i
i.y = h
k.x = n
k.y = n
k.s = d
d.p = n
d.y = i
d.q = k
d.s = h
n.w = k
n.y = i
n.q = h
c.w = k
c.y = i
c.q = h
assert k.s.q.y.w.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: E = None
        self.s: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: E = None
        self.y: B = None
        self.q: C = None
        self.s: A = None
        self.txt = txt

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

h = A("h")
i = B("i")
k = C("k")
d = D("d")
n = E("n")
c = E("c")

h.r = d
h.w = c
h.s = i
i.y = h
k.x = n
k.y = n
k.s = d
d.p = n
d.y = i
d.q = k
d.s = h
n.w = k
n.y = i
n.q = h
c.w = k
c.y = i
c.q = h
assert k.s.q.y.w.s.q.txt == "k"