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

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

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

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

m = A("m")
j = B("j")
f = C("f")
b = D("b")

m.o = f
m.y = f
j.w = m
j.v = b
f.z = j
f.y = j
f.s = b
f.x = b
b.x = f
b.t = f
b.z = m
b.y = j
assert j.w.o.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.y: C = None
        self.txt = txt

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

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

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

m = A("m")
j = B("j")
f = C("f")
b = D("b")

m.o = f
m.y = f
j.w = m
j.v = b
f.z = j
f.y = j
f.s = b
f.x = b
b.x = f
b.t = f
b.z = m
b.y = j
assert j.w.o.x.z.txt == "m"