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

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

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

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

c = A("c")
f = B("f")
a = C("a")
i = D("i")
g = D("g")
n = A("n")
j = A("j")
h = C("h")
m = C("m")
k = B("k")

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

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

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

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

c = A("c")
f = B("f")
a = C("a")
i = D("i")
g = D("g")
n = A("n")
j = A("j")
h = C("h")
m = C("m")
k = B("k")

c.v = g
c.p = g
c.s = n
f.w = n
f.r = k
f.s = i
a.z = i
a.y = m
a.x = c
a.w = h
i.r = g
g.r = i
n.v = g
n.s = j
n.p = i
j.v = g
j.s = n
j.p = i
h.z = g
h.y = a
h.x = n
h.w = m
m.z = i
m.y = a
m.w = a
m.x = c
k.w = c
k.r = f
k.s = g
assert a.x.s.p.r.r.r.txt == "g"