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

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

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

d = A("d")
n = B("n")
b = C("b")
i = A("i")
c = B("c")
m = B("m")
f = B("f")
g = C("g")
k = B("k")

d.p = m
d.v = g
d.z = f
n.s = g
n.w = d
n.r = b
b.o = i
b.y = i
b.w = g
i.p = c
i.v = b
i.z = m
c.s = b
c.w = i
c.r = g
m.s = g
m.r = g
m.w = i
f.s = g
f.r = g
f.w = i
g.o = d
g.y = i
g.w = b
k.s = b
k.r = b
k.w = d
assert f.s.o.v.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: C = None
        self.z: B = None
        self.txt = txt

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

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

d = A("d")
n = B("n")
b = C("b")
i = A("i")
c = B("c")
m = B("m")
f = B("f")
g = C("g")
k = B("k")

d.p = m
d.v = g
d.z = f
n.s = g
n.w = d
n.r = b
b.o = i
b.y = i
b.w = g
i.p = c
i.v = b
i.z = m
c.s = b
c.w = i
c.r = g
m.s = g
m.r = g
m.w = i
f.s = g
f.r = g
f.w = i
g.o = d
g.y = i
g.w = b
k.s = b
k.r = b
k.w = d
assert f.s.o.v.o.p.txt == "m"