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

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

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.t: A = None
        self.v: B = None
        self.txt = txt

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

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

f = A("f")
i = B("i")
k = C("k")
g = D("g")
a = E("a")

f.q = k
f.p = i
f.z = g
i.t = k
i.r = f
i.y = a
k.s = i
k.v = i
k.t = f
g.q = k
a.q = i
a.x = k
a.s = k
a.r = f
assert g.q.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: B = None
        self.z: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.t: A = None
        self.v: B = None
        self.txt = txt

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

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

f = A("f")
i = B("i")
k = C("k")
g = D("g")
a = E("a")

f.q = k
f.p = i
f.z = g
i.t = k
i.r = f
i.y = a
k.s = i
k.v = i
k.t = f
g.q = k
a.q = i
a.x = k
a.s = k
a.r = f
assert g.q.v.t.txt == "k"