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

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

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

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

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

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

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

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

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

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

f.p = h
f.v = m
m.s = f
m.y = j
h.u = f
h.v = j
j.z = f
j.u = m
j.y = h
assert j.y.v.z.v.txt == "m"