(CNN) -- A trip to Iran to learn more about her family's ancestry became a nightmare for American journalist Roxana Saberi. In January 2009, while she was working in the country, several men showed up at the Iranian-American's door and carted her off to Evin Prison, the notoriously brutal lockup outside Tehran where three American hikers were recently imprisoned. Like Josh Fattal, Sarah Shourd and Shane Bauer, Saberi was accused of being a spy for the U.S.
Like them, she denied the accusation. Iran tried, convicted and sentenced Saberi to eight years. But, to her shock, she was freed after 100 days. She returned to the U.S. in May 2009.
On Wednesday, Fattal and Bauer were freed after two years at Evin. Shourd was released last year.
CNN talked with Saberi about the advice she would give the hikers and about her experience at Evin.
CNN: Did you ever hope that you might be set free, even after your sentence?
Roxana Saberi: I didn't think I was going to be set free after being sentenced to eight years. When they said I was going to be freed, I was in disbelief, very happy disbelief.
CNN: You wrote in your book that about gaining a unique kind of mental clarity and toughness.
Saberi: I learned over time, especially from my cellmates, that things happen to you, and you can't control them. All you can control is your response to them. In prison, you cannot control your physical environment.
CNN: You can say that, but to actually live that way under those circumstances is another thing. You were interrogated for days on end.
Saberi: (The interrogators) were mostly harsh and threatening, but then they would say, "Oh, are you hungry? Do you want us to make you comfortable? Do you want some tea or some water?" I think it was partly to mess with the person's mind. My cellmates, the women who were prisoners, they are the strong ones. There were times when I was angry and told myself that I hate the sin and not the sinner. I had to learn from my cellmates, who were in prison much longer. I asked them, "How do you not hate these people for doing this to you?"
(Saberi says she nurtured relationships with other prisoners by teaching them English. Many, she says, were at Evin for believing in Baha'i, a monotheistic faith believers are persecuted for in Iran.)
Saberi: These prisoners told me, "We don't hate (the guards), but we forgive them," which was incredible to me. I tried hard to hate the sin and not the sinner. ... I realized we are all human beings, and (the prison workers) do their jobs to have job security. They get paid for it. Some of them do believe in the ideology, and some don't. If our captors, I believe, were raised in a different environment, they wouldn't do what they do.
But I really got a lot of strength from other prisoners. We taught each other jokes in our different languages. I taught them vocabulary that had to do with shopping and English curse words. We exercised.
CNN: How did you exercise?
Saberi: Sit-ups, push-ups in our cell. We were allowed to go outside four times a week, escorted by guards who pushed at the chadors we had to wear. The guards would take us to a cement cage -- the walls, all cement and bars. Overhead them, at least you could see sky.
CNN: When the guards were marching you back and forth, did you say anything to them? Did they speak to you?
Saberi: They mostly didn't say anything. (But) a female guard -- she was older -- reached under my chador and grabbed my hand and squeezed it.
CNN: Did you see any other humanity like that in your guards?
Saberi: There was humanity in some of them, in this female guard. She seemed to be trying to tell me that everyone would be OK. Toward me, the guards were mostly civil. I did see them yelling at other prisoners. I assume that because I was a foreigner, and Iranians say they are kind to foreigners.
We tried to learn more about the women guards, because they would stop by our cells when they were giving us food. They were very tight-lipped and were instructed not to say much about themselves. We got tidbits about their lives. One had kids, and one had a nose job; this kind of plastic surgery is very popular in Iran. They had the same values -- caring about how they looked -- like other women would have. But I didn't get that close with any of them. They don't allow it.
CNN: Tell me more about how you kept sane, especially in solitary confinement. How did you even keep track of time?
Saberi: Well, I thought I was going crazy. I was in solitary for more than two weeks; then I was sent to a cell that had state-run TV playing so I could see the time. I could hear the call to prayer and see sun rays cast on the cell walls and floors.
CNN: Can you describe what solitary confinement was like?
Saberi: I could hold my hands out and almost touch two walls. There was ratty brown carpet. There was a broken toilet. Military blankets. A sign on the wall quoted (founder and supreme leader of the Islamic Republic of Iran Ayatollah) Khomeini said, "Prisons must be colleges for human improvement." There was a window just below the ceiling out of reach that was covered with metal mesh and bars. On the other side of my wall, I heard a prisoner whimpering.
I was very worried, because no one knew where I was. (Saberi wrote in her memoir "Between Two Worlds: My Life and Captivity in Iran" that only after many days did Iranian authorities allow her to call her father. They forced her to lie to him in saying that she didn't know where she was and that she was in trouble for drinking alcohol.)
I tried to keep my sanity by singing songs like Christmas carols and "We Will Rock you," and I played notes with my fingers on the wall. I kept saying things that gave me courage like Gandhi's "I do believe I am seeking only God's truth and have lost all fear of man."
CNN: When you were let out of solitary, what happened?
Saberi: They put me in another cell.
CNN: And you were held for four months. What did you think when news came last week when the Iranian president said that Josh Fattal and Shane Bauer were going to be released? And what did you think when they were freed Wednesday?
Saberi: In Iran, you never believe it until you see it. I thought about their families.
CNN: You've talked to their families before.
Saberi: I could relate to how worried they were. My parents were in a similar situation. I wanted to comfort them and to explain what prison was like for me.
CNN: What would you say to Josh and Shane now?
Saberi: I'd like to hear from them how their situation was. I hope that they are able to adapt well in this new part of their life and perhaps learned lessons in prison that can help them when they're free. I would tell them to take their time and not feel pressured to make decisions. This is their time. It's theirs again.