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

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

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

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

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

h.p = e
k.w = e
k.p = e
k.q = e
k.v = m
m.z = e
m.s = h
m.o = c
e.r = c
e.w = c
e.u = k
e.s = m
c.p = e
a.w = e
a.p = e
a.q = e
a.v = f
f.z = e
f.s = c
f.o = h
assert e.s.z.w.p.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

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

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

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

h.p = e
k.w = e
k.p = e
k.q = e
k.v = m
m.z = e
m.s = h
m.o = c
e.r = c
e.w = c
e.u = k
e.s = m
c.p = e
a.w = e
a.p = e
a.q = e
a.v = f
f.z = e
f.s = c
f.o = h
assert e.s.z.w.p.u.v.txt == "m"