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

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

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

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

j = A("j")
c = B("c")
g = C("g")
i = D("i")
b = A("b")

j.v = i
c.y = g
g.t = c
i.q = g
i.z = c
i.s = c
i.o = j
b.v = i
assert j.v.q.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

j = A("j")
c = B("c")
g = C("g")
i = D("i")
b = A("b")

j.v = i
c.y = g
g.t = c
i.q = g
i.z = c
i.s = c
i.o = j
b.v = i
assert j.v.q.t.y.txt == "g"