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

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

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

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

h = A("h")
e = B("e")
f = C("f")
j = D("j")

h.p = f
h.s = f
h.z = f
h.u = e
e.s = f
e.w = h
f.y = e
f.p = e
j.p = h
j.z = e
j.s = e
j.y = e
assert e.s.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.s: C = None
        self.u: B = None
        self.z: C = None
        self.txt = txt

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

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

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

h = A("h")
e = B("e")
f = C("f")
j = D("j")

h.p = f
h.s = f
h.z = f
h.u = e
e.s = f
e.w = h
f.y = e
f.p = e
j.p = h
j.z = e
j.s = e
j.y = e
assert e.s.y.w.txt == "h"