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

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

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

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

a = A("a")
j = B("j")
n = C("n")
d = D("d")

a.x = d
j.r = d
j.v = d
j.q = a
j.x = a
n.q = d
n.w = a
d.o = j
d.y = n
d.q = n
d.t = a
assert n.q.y.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

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

a = A("a")
j = B("j")
n = C("n")
d = D("d")

a.x = d
j.r = d
j.v = d
j.q = a
j.x = a
n.q = d
n.w = a
d.o = j
d.y = n
d.q = n
d.t = a
assert n.q.y.q.o.txt == "j"