--神心一刀流·樱舞回天
function c66914007.initial_effect(c)
	--Activate
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetCountLimit(1,66914007)
	e1:SetTarget(c66914007.target)
	e1:SetOperation(c66914007.activate)
	c:RegisterEffect(e1)	
	--set
	local e3=Effect.CreateEffect(c)
	e3:SetDescription(aux.Stringid(66914007,1))
	e3:SetCategory(CATEGORY_LEAVE_GRAVE)
	e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
	e3:SetCode(EVENT_CHAINING)
	e3:SetProperty(EFFECT_FLAG_DELAY)
	e3:SetRange(LOCATION_GRAVE)
	e3:SetCountLimit(1,66914007)
	e3:SetCondition(c66914007.condition)
	e3:SetTarget(c66914007.settg)
	e3:SetOperation(c66914007.setop)
	c:RegisterEffect(e3)
end
function c66914007.target(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return true end
end
function c66914007.activate(e,tp,eg,ep,ev,re,r,rp)
	if Duel.GetFlagEffect(tp,66914007)~=0 then
		Duel.RegisterFlagEffect(tp,66914006,RESET_PHASE+PHASE_END,0,1)   
	else
		Duel.RegisterFlagEffect(tp,66914007,RESET_PHASE+PHASE_END,0,1)
	end
end
function c66914007.condition(e,tp,eg,ep,ev,re,r,rp)
	return Duel.GetTurnPlayer()==tp and rp==tp and re:GetHandler():IsSetCard(0x373)
end
function c66914007.settg(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return e:GetHandler():IsSSetable() end
	Duel.SetOperationInfo(0,CATEGORY_LEAVE_GRAVE,e:GetHandler(),1,0,0)
end
function c66914007.setop(e,tp,eg,ep,ev,re,r,rp)
	local c=e:GetHandler()
	if c:IsRelateToEffect(e) and Duel.SSet(tp,c)~=0 then
		local e1=Effect.CreateEffect(c)
		e1:SetType(EFFECT_TYPE_SINGLE)
		e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
		e1:SetReset(RESET_EVENT+RESETS_REDIRECT)
		e1:SetValue(LOCATION_DECK)
		c:RegisterEffect(e1)
	end
end