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

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

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

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

j = A("j")
h = B("h")
f = C("f")
d = D("d")
l = C("l")

j.s = h
j.v = h
j.r = d
j.x = l
h.z = j
h.q = j
h.u = d
h.o = f
f.s = h
f.t = j
d.u = j
d.x = h
l.s = h
l.t = j
assert d.x.o.s.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.v: B = None
        self.r: D = None
        self.x: C = None
        self.txt = txt

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

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

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

j = A("j")
h = B("h")
f = C("f")
d = D("d")
l = C("l")

j.s = h
j.v = h
j.r = d
j.x = l
h.z = j
h.q = j
h.u = d
h.o = f
f.s = h
f.t = j
d.u = j
d.x = h
l.s = h
l.t = j
assert d.x.o.s.o.t.txt == "j"