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

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

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: A = None
        self.p: B = None
        self.x: B = None
        self.o: B = None
        self.txt = txt

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

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

n = A("n")
m = B("m")
i = C("i")
j = D("j")
a = E("a")

n.y = a
m.r = i
i.v = j
i.y = n
i.p = m
i.x = m
i.o = m
j.t = n
a.x = m
a.t = n
assert j.t.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: A = None
        self.p: B = None
        self.x: B = None
        self.o: B = None
        self.txt = txt

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

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

n = A("n")
m = B("m")
i = C("i")
j = D("j")
a = E("a")

n.y = a
m.r = i
i.v = j
i.y = n
i.p = m
i.x = m
i.o = m
j.t = n
a.x = m
a.t = n
assert j.t.y.x.txt == "m"