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

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

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

n = A("n")
f = B("f")
j = C("j")
h = C("h")
l = B("l")
b = C("b")

n.p = j
n.v = h
f.w = b
j.s = f
j.v = l
j.r = n
h.s = f
h.v = f
h.r = n
l.w = j
b.s = l
b.v = f
b.r = n
assert n.v.r.v.r.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.v: C = None
        self.txt = txt

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

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

n = A("n")
f = B("f")
j = C("j")
h = C("h")
l = B("l")
b = C("b")

n.p = j
n.v = h
f.w = b
j.s = f
j.v = l
j.r = n
h.s = f
h.v = f
h.r = n
l.w = j
b.s = l
b.v = f
b.r = n
assert n.v.r.v.r.v.r.txt == "n"