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

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

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

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

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

i = A("i")
h = B("h")
g = C("g")
j = D("j")
l = E("l")
a = C("a")
e = E("e")

i.y = j
h.v = i
h.r = l
g.s = e
j.z = g
j.s = i
l.w = j
a.s = e
e.w = j
assert h.r.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

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

i = A("i")
h = B("h")
g = C("g")
j = D("j")
l = E("l")
a = C("a")
e = E("e")

i.y = j
h.v = i
h.r = l
g.s = e
j.z = g
j.s = i
l.w = j
a.s = e
e.w = j
assert h.r.w.z.txt == "g"