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

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

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

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

m = A("m")
k = B("k")
f = C("f")
l = D("l")
a = B("a")
c = B("c")
g = A("g")
h = C("h")

m.v = f
k.z = l
k.o = c
k.s = g
k.p = a
f.y = g
f.z = g
f.s = m
l.s = g
a.z = l
a.o = c
a.p = c
a.s = g
c.z = l
c.o = a
c.p = a
c.s = m
g.v = f
h.y = g
h.s = g
h.z = m
assert f.s.v.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

m = A("m")
k = B("k")
f = C("f")
l = D("l")
a = B("a")
c = B("c")
g = A("g")
h = C("h")

m.v = f
k.z = l
k.o = c
k.s = g
k.p = a
f.y = g
f.z = g
f.s = m
l.s = g
a.z = l
a.o = c
a.p = c
a.s = g
c.z = l
c.o = a
c.p = a
c.s = m
g.v = f
h.y = g
h.s = g
h.z = m
assert f.s.v.z.v.txt == "f"