class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.x: C = None
        self.t: B = None
        self.y: D = 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.w: B = None
        self.txt = txt

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

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

k = A("k")
n = B("n")
i = C("i")
j = D("j")
g = E("g")
l = A("l")

k.r = n
k.t = n
k.x = i
k.y = j
n.r = i
i.w = n
j.s = k
g.s = i
g.t = l
g.y = j
l.r = n
l.t = n
l.x = i
l.y = j
assert l.x.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.x: C = None
        self.t: B = None
        self.y: D = 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.w: B = None
        self.txt = txt

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

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

k = A("k")
n = B("n")
i = C("i")
j = D("j")
g = E("g")
l = A("l")

k.r = n
k.t = n
k.x = i
k.y = j
n.r = i
i.w = n
j.s = k
g.s = i
g.t = l
g.y = j
l.r = n
l.t = n
l.x = i
l.y = j
assert l.x.w.r.txt == "i"