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

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

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

n = A("n")
e = B("e")
g = C("g")
h = B("h")
b = C("b")
k = A("k")

n.s = h
n.p = h
n.r = k
e.z = n
e.v = n
g.v = e
g.o = e
g.y = e
h.z = n
h.v = k
b.v = h
b.o = h
b.y = e
k.s = h
k.p = h
k.r = n
assert e.v.r.r.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.p: B = None
        self.r: A = None
        self.txt = txt

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

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

n = A("n")
e = B("e")
g = C("g")
h = B("h")
b = C("b")
k = A("k")

n.s = h
n.p = h
n.r = k
e.z = n
e.v = n
g.v = e
g.o = e
g.y = e
h.z = n
h.v = k
b.v = h
b.o = h
b.y = e
k.s = h
k.p = h
k.r = n
assert e.v.r.r.p.v.txt == "k"