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

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

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

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

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

m.s = n
m.z = n
m.w = f
m.t = b
f.r = j
f.o = n
n.p = b
n.x = j
n.r = j
j.x = f
b.s = n
b.z = n
b.w = f
b.t = h
h.s = n
h.z = n
h.w = f
h.t = m
assert f.o.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.w: B = None
        self.z: C = None
        self.t: A = None
        self.txt = txt

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

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

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

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

m.s = n
m.z = n
m.w = f
m.t = b
f.r = j
f.o = n
n.p = b
n.x = j
n.r = j
j.x = f
b.s = n
b.z = n
b.w = f
b.t = h
h.s = n
h.z = n
h.w = f
h.t = m
assert f.o.p.s.txt == "n"