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

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

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

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

a = A("a")
j = B("j")
k = C("k")
l = D("l")

a.o = k
a.r = k
a.q = j
a.v = j
j.v = k
k.t = a
k.q = a
k.w = a
l.s = j
l.t = a
assert k.q.o.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.q: B = None
        self.r: C = None
        self.v: B = None
        self.txt = txt

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

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

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

a = A("a")
j = B("j")
k = C("k")
l = D("l")

a.o = k
a.r = k
a.q = j
a.v = j
j.v = k
k.t = a
k.q = a
k.w = a
l.s = j
l.t = a
assert k.q.o.t.q.txt == "j"