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

class B:
    def __init__(self, txt: str):
        self.v: A = 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.p: C = None
        self.o: A = None
        self.y: B = None
        self.v: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: A = None
        self.o: D = None
        self.v: C = None
        self.w: B = None
        self.txt = txt

k = A("k")
g = B("g")
m = C("m")
i = D("i")
c = E("c")

k.v = i
k.y = i
g.v = k
m.s = c
i.p = m
i.o = k
i.v = k
i.y = g
c.x = g
c.w = g
c.s = k
c.o = i
c.v = m
assert m.s.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = 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.p: C = None
        self.o: A = None
        self.y: B = None
        self.v: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: A = None
        self.o: D = None
        self.v: C = None
        self.w: B = None
        self.txt = txt

k = A("k")
g = B("g")
m = C("m")
i = D("i")
c = E("c")

k.v = i
k.y = i
g.v = k
m.s = c
i.p = m
i.o = k
i.v = k
i.y = g
c.x = g
c.w = g
c.s = k
c.o = i
c.v = m
assert m.s.x.v.txt == "k"