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

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

c = A("c")
i = B("i")
n = B("n")
d = A("d")
k = A("k")
h = B("h")

c.s = n
c.r = d
i.w = h
i.v = d
n.w = i
n.v = k
d.s = n
d.r = c
k.s = h
k.r = d
h.w = i
h.v = k
assert n.v.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.r: A = None
        self.txt = txt

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

c = A("c")
i = B("i")
n = B("n")
d = A("d")
k = A("k")
h = B("h")

c.s = n
c.r = d
i.w = h
i.v = d
n.w = i
n.v = k
d.s = n
d.r = c
k.s = h
k.r = d
h.w = i
h.v = k
assert n.v.r.r.txt == "c"