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

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

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

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

d = A("d")
h = B("h")
j = C("j")
g = D("g")

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

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

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

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

d = A("d")
h = B("h")
j = C("j")
g = D("g")

d.s = g
d.t = j
h.y = g
h.r = d
j.q = d
j.y = d
j.o = d
j.s = g
g.v = h
g.r = d
g.q = d
g.z = j
assert j.s.v.r.txt == "d"