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

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

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

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

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

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

m.r = k
d.s = n
k.q = n
k.p = d
k.y = m
a.t = d
a.w = n
n.v = k
assert a.w.v.y.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

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

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

m.r = k
d.s = n
k.q = n
k.p = d
k.y = m
a.t = d
a.w = n
n.v = k
assert a.w.v.y.r.p.txt == "d"