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

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

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.p: E = None
        self.txt = txt

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

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

j = A("j")
k = B("k")
h = C("h")
i = D("i")
c = E("c")

j.w = h
j.u = h
j.r = h
j.q = c
k.u = i
h.v = i
h.p = c
i.s = h
i.u = h
i.p = j
i.v = c
c.v = k
assert j.w.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.u: C = None
        self.q: E = None
        self.r: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.p: E = None
        self.txt = txt

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

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

j = A("j")
k = B("k")
h = C("h")
i = D("i")
c = E("c")

j.w = h
j.u = h
j.r = h
j.q = c
k.u = i
h.v = i
h.p = c
i.s = h
i.u = h
i.p = j
i.v = c
c.v = k
assert j.w.v.p.txt == "j"