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

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

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

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

j = A("j")
k = B("k")
i = C("i")
d = D("d")

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

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

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

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

j = A("j")
k = B("k")
i = C("i")
d = D("d")

j.q = i
j.r = i
j.v = k
j.t = d
k.x = d
k.u = d
k.p = d
i.r = d
i.s = j
i.x = j
d.y = j
assert k.u.y.q.txt == "i"