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

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

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

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

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

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

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

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

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

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

d.q = j
d.r = e
j.o = k
k.y = e
k.t = j
k.v = j
e.o = d
e.x = j
assert k.t.o.y.x.txt == "j"