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

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

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

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

j = A("j")
e = B("e")
n = C("n")
k = D("k")

j.w = k
j.y = k
e.v = j
e.q = k
e.u = n
n.p = k
n.r = e
k.p = e
k.v = e
k.y = j
assert e.q.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.y: D = None
        self.txt = txt

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

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

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

j = A("j")
e = B("e")
n = C("n")
k = D("k")

j.w = k
j.y = k
e.v = j
e.q = k
e.u = n
n.p = k
n.r = e
k.p = e
k.v = e
k.y = j
assert e.q.p.q.txt == "k"