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

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

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

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

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

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

k.r = j
k.x = i
l.q = c
l.z = c
l.r = c
l.u = i
c.r = l
c.q = j
i.y = j
i.v = c
i.q = c
j.y = k
assert j.y.r.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.x: D = None
        self.txt = txt

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

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

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

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

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

k.r = j
k.x = i
l.q = c
l.z = c
l.r = c
l.u = i
c.r = l
c.q = j
i.y = j
i.v = c
i.q = c
j.y = k
assert j.y.r.y.x.txt == "i"