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

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

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.y: A = None
        self.p: A = None
        self.o: A = None
        self.txt = txt

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

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

n = A("n")
h = B("h")
j = C("j")
c = D("c")
f = E("f")

n.y = f
h.w = c
h.v = n
j.s = h
j.y = n
j.p = n
j.o = n
c.u = n
c.v = n
c.o = f
c.q = j
f.q = j
assert n.y.q.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.y: A = None
        self.p: A = None
        self.o: A = None
        self.txt = txt

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

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

n = A("n")
h = B("h")
j = C("j")
c = D("c")
f = E("f")

n.y = f
h.w = c
h.v = n
j.s = h
j.y = n
j.p = n
j.o = n
c.u = n
c.v = n
c.o = f
c.q = j
f.q = j
assert n.y.q.s.v.txt == "n"