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

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

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

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

j = A("j")
l = B("l")
h = C("h")
e = D("e")

j.o = h
l.q = e
h.s = l
h.x = l
h.r = e
h.v = e
e.q = l
assert j.o.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

j = A("j")
l = B("l")
h = C("h")
e = D("e")

j.o = h
l.q = e
h.s = l
h.x = l
h.r = e
h.v = e
e.q = l
assert j.o.s.q.txt == "e"