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

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

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

i.r = j
i.w = h
g.q = l
e.q = i
j.z = a
j.x = l
c.y = a
h.r = j
h.w = i
a.y = c
l.q = g
assert h.w.w.r.z.y.y.y.y.txt == "a"