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

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

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

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

g = A("g")
i = B("i")
m = C("m")
b = D("b")
c = B("c")
a = A("a")
h = A("h")
f = A("f")

g.s = b
g.v = b
g.p = m
i.p = b
i.z = a
m.x = b
m.r = g
m.y = h
b.x = h
b.v = f
c.p = b
c.z = a
a.s = b
a.v = b
a.p = m
h.s = b
h.v = b
h.p = m
f.s = b
f.v = b
f.p = m
assert g.p.y.p.y.p.r.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.p: C = None
        self.v: D = None
        self.txt = txt

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

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

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

g = A("g")
i = B("i")
m = C("m")
b = D("b")
c = B("c")
a = A("a")
h = A("h")
f = A("f")

g.s = b
g.v = b
g.p = m
i.p = b
i.z = a
m.x = b
m.r = g
m.y = h
b.x = h
b.v = f
c.p = b
c.z = a
a.s = b
a.v = b
a.p = m
h.s = b
h.v = b
h.p = m
f.s = b
f.v = b
f.p = m
assert g.p.y.p.y.p.r.v.x.txt == "h"