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

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

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

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

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

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

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

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

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

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

d.y = j
d.z = j
d.v = h
d.x = g
j.z = h
g.o = d
g.u = d
g.z = d
g.r = h
h.y = j
h.o = j
assert j.z.o.z.y.txt == "j"