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

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

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

j = A("j")
n = B("n")
l = C("l")
d = B("d")

j.s = d
j.y = l
n.y = j
n.w = j
n.r = d
l.v = n
d.y = j
d.w = j
d.r = n
assert j.y.v.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.y: C = None
        self.txt = txt

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

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

j = A("j")
n = B("n")
l = C("l")
d = B("d")

j.s = d
j.y = l
n.y = j
n.w = j
n.r = d
l.v = n
d.y = j
d.w = j
d.r = n
assert j.y.v.r.r.txt == "n"