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

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

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

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

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

l = A("l")
d = B("d")
j = C("j")
e = D("e")
n = E("n")
a = D("a")
k = E("k")

l.t = e
d.y = n
d.w = l
j.r = d
e.x = k
n.r = d
a.x = k
k.r = d
assert j.r.y.r.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

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

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

l = A("l")
d = B("d")
j = C("j")
e = D("e")
n = E("n")
a = D("a")
k = E("k")

l.t = e
d.y = n
d.w = l
j.r = d
e.x = k
n.r = d
a.x = k
k.r = d
assert j.r.y.r.y.r.txt == "d"