class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

k = A("k")
c = B("c")
e = A("e")
g = B("g")
l = A("l")
h = B("h")
a = A("a")
j = B("j")
b = A("b")
n = A("n")

k.p = e
c.u = j
e.p = n
g.u = j
l.p = n
h.u = g
a.p = n
j.u = c
b.p = a
n.p = k
assert c.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

k = A("k")
c = B("c")
e = A("e")
g = B("g")
l = A("l")
h = B("h")
a = A("a")
j = B("j")
b = A("b")
n = A("n")

k.p = e
c.u = j
e.p = n
g.u = j
l.p = n
h.u = g
a.p = n
j.u = c
b.p = a
n.p = k
assert c.u.u.u.u.txt == "c"