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

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

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

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.x: C = None
        self.txt = txt

m = A("m")
b = B("b")
n = C("n")
g = D("g")
f = B("f")

m.s = b
m.r = f
b.w = f
b.u = n
b.y = g
b.q = m
n.u = m
n.s = f
g.o = n
g.x = n
f.w = b
f.u = n
f.y = g
f.q = m
assert m.s.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.r: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.x: C = None
        self.txt = txt

m = A("m")
b = B("b")
n = C("n")
g = D("g")
f = B("f")

m.s = b
m.r = f
b.w = f
b.u = n
b.y = g
b.q = m
n.u = m
n.s = f
g.o = n
g.x = n
f.w = b
f.u = n
f.y = g
f.q = m
assert m.s.y.o.txt == "n"