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

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

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

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

f = A("f")
b = B("b")
i = C("i")
a = D("a")
m = A("m")

f.p = i
f.s = b
f.x = m
f.u = m
b.s = i
b.u = a
i.w = m
i.v = m
i.p = f
i.y = a
a.w = i
m.p = i
m.s = b
m.x = f
m.u = f
assert a.w.y.w.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.s: B = None
        self.x: A = None
        self.u: A = None
        self.txt = txt

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

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

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

f = A("f")
b = B("b")
i = C("i")
a = D("a")
m = A("m")

f.p = i
f.s = b
f.x = m
f.u = m
b.s = i
b.u = a
i.w = m
i.v = m
i.p = f
i.y = a
a.w = i
m.p = i
m.s = b
m.x = f
m.u = f
assert a.w.y.w.p.s.txt == "b"