first node in the cycle is a node with 2 other nodes pointing at:

what can be done, is iterate over the list, keep all node addresses and check when address was already recorded. this address is the loop begin node.
Sample code:
#include "stdio.h"
#include <iostream>
#include <vector>
struct ListNode
{
struct ListNode* next;
};
ListNode* detectCycle(ListNode* A) {
ListNode* p = A;
ListNode* q = A;
while (p != NULL && q != NULL && q->next != NULL)
{
p = p->next;
q = q->next->next;
if (p == q)
{
p = A;
while (p != q)
{
p = p->next;
q = q->next;
}
return p;
}
}
return NULL;
}
template < typename T>
std::pair<bool, int > findInVector(const std::vector<T>& vecOfElements, const T& element)
{
std::pair<bool, int > result;
// Find given element in vector
auto it = std::find(vecOfElements.begin(), vecOfElements.end(), element);
if (it != vecOfElements.end())
{
result.second = distance(vecOfElements.begin(), it);
result.first = true;
}
else
{
result.first = false;
result.second = -1;
}
return result;
}
int main()
{
ListNode a, b, c, d, e, f; // a -> b -> c -> d ->e -> f -> c;
a.next = &b;
b.next = &c;
c.next = &d;
d.next = &e;
e.next = &f;
f.next = &c;
ListNode* p = detectCycle(&a);
std::cout << p;
std::vector<ListNode*> v;
v.push_back(&a);
ListNode* it = a.next;
while (findInVector(v, it).first == false)
{
v.push_back(it);
it = it->next;
}
std::cout << " first is " << v.at(findInVector(v, it).second) << " " << &c;
}