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

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

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

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

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

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

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

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

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

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

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