function Dice(labels) {
    this.top = labels[0];
    this.back = labels[1];
    this.right = labels[2];
    this.left = labels[3];
    this.front = labels[4];
    this.bottom = labels[5];
};

Dice.prototype.roll = function(direction) {
    switch (direction) {
        case 'W':
            var tmp = this.left;
            this.left = this.top;
            this.top = this.right;
            this.right = this.bottom;
            this.bottom = tmp;
            break;
        case 'N':
            var tmp = this.front;
            this.front = this.top;
            this.top = this.back;
            this.back = this.bottom;
            this.bottom = tmp;
            break;
        case 'E':
            var tmp = this.right;
            this.right = this.top;
            this.top = this.left;
            this.left = this.bottom;
            this.bottom = tmp;
            break;
        case 'S':
            var tmp = this.back;
            this.back = this.top;
            this.top = this.front;
            this.front = this.bottom;
            this.bottom = tmp;
            break;
    }
};

Dice.prototype.rollToTop = function(top) {
    if (top === this.right) {
        this.roll('W');
    } else if (top === this.left) {
        this.roll('E');
    } else if (top === this.back) {
        this.roll('N');
    } else if (top === this.front) {
        this.roll('S');
    }
};

Dice.prototype.getRightWithTopAndBack = function(top, back) {
    if (top === this.top) {
        if (back === this.back) {
            return this.right;
        }
        if (back === this.left) {
            return this.back;
        }
        if (back === this.front) {
            return this.left;
        }
        if (back === this.right) {
            return this.front;
        }
    }
    if (top === this.front) {
        if (back === this.top) {
            return this.right;
        }
        if (back === this.left) {
            return this.top;
        }
        if (back === this.bottom) {
            return this.left;
        }
        if (back === this.right) {
            return this.bottom;
        }
    }
    if (top === this.bottom) {
        if (back === this.front) {
            return this.right;
        }
        if (back === this.left) {
            return this.front;
        }
        if (back === this.back) {
            return this.left;
        }
        if (back === this.right) {
            return this.back;
        }
    }
    if (top === this.back) {
        if (back === this.bottom) {
            return this.right;
        }
        if (back === this.left) {
            return this.bottom;
        }
        if (back === this.top) {
            return this.left;
        }
        if (back === this.right) {
            return this.top;
        }
    }
    if (top === this.right) {
        if (back === this.bottom) {
            return this.front;
        }
        if (back === this.back) {
            return this.bottom;
        }
        if (back === this.top) {
            return this.back;
        }
        if (back === this.front) {
            return this.top;
        }
    }
    if (top === this.left) {
        if (back === this.top) {
            return this.front;
        }
        if (back === this.front) {
            return this.bottom;
        }
        if (back === this.bottom) {
            return this.back;
        }
        if (back === this.back) {
            return this.top;
        }
    }
};

Dice.prototype.isEqual = function(other) {
    return (this.right === other.getRightWithTopAndBack(this.top, this.back) || this.top === this.back)
        && (this.front === other.getRightWithTopAndBack(this.bottom, this.left) || this.bottom === this.left);
};

(function(input) {
    var p = input.split('\n');
    var labels1 = p.shift().split(' ').map(Number);
    var labels2 = p.shift().split(' ').map(Number);
    var dice1 = new Dice(labels1);
    var dice2 = new Dice(labels2);
    console.log(dice1.isEqual(dice2) ? 'Yes' : 'No');
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7648