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

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

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

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

i.y = n
i.r = b
f.s = l
n.x = f
b.y = n
b.r = j
j.y = n
j.r = i
l.s = f
assert i.r.r.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.r: A = None
        self.txt = txt

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

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

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

i.y = n
i.r = b
f.s = l
n.x = f
b.y = n
b.r = j
j.y = n
j.r = i
l.s = f
assert i.r.r.r.y.txt == "n"