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

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

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

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

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

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

d.t = n
l.y = n
m.r = n
n.s = l
n.y = l
n.v = d
a.s = d
assert d.t.y.y.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

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

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

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

d.t = n
l.y = n
m.r = n
n.s = l
n.y = l
n.v = d
a.s = d
assert d.t.y.y.s.y.txt == "n"