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

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

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

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

d = A("d")
j = B("j")
l = C("l")
i = D("i")
n = D("n")

d.w = l
j.q = l
l.p = j
i.w = d
i.t = j
n.w = d
n.t = j
assert j.q.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

d = A("d")
j = B("j")
l = C("l")
i = D("i")
n = D("n")

d.w = l
j.q = l
l.p = j
i.w = d
i.t = j
n.w = d
n.t = j
assert j.q.p.q.txt == "l"